64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { SpriteFrame } from 'cc';
|
|
import { Prefab } from 'cc';
|
|
import { SpriteAtlas } from 'cc';
|
|
import { _decorator, Component, Node } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('GameAssets')
|
|
export class GameAssets extends Component {
|
|
// @property(SpriteAtlas) public assetAtlas: SpriteAtlas = null!;
|
|
public static instance: GameAssets = null!;
|
|
|
|
@property(Prefab) heroPrefab: Prefab = null!;
|
|
@property(Prefab) creepMeleePrefab: Prefab = null!;
|
|
@property(Prefab) creepRangePrefab: Prefab = null!;
|
|
@property(Prefab) activeSkillPrefabs: Prefab[] = [];
|
|
@property(Prefab) bossMeleePrefab: Prefab = null!;
|
|
@property(Prefab) bossRangePrefab: Prefab = null!;
|
|
@property(Prefab) bossSlowPrefab: Prefab = null!;
|
|
@property(Prefab) psIconPrefabs: Prefab[] = [];
|
|
@property(Prefab) asIconPrefabs: Prefab[] = [];
|
|
|
|
protected onLoad(): void {
|
|
GameAssets.instance = this;
|
|
}
|
|
|
|
public getActiveSkill(type: number): Prefab
|
|
{
|
|
if (type >= 0 && type < this.activeSkillPrefabs.length)
|
|
return this.activeSkillPrefabs[type];
|
|
|
|
return null;
|
|
}
|
|
|
|
public getBossPrefabById(bossId: string)
|
|
{
|
|
switch (bossId)
|
|
{
|
|
case "B1":
|
|
return this.bossMeleePrefab;
|
|
|
|
case "B2":
|
|
return this.bossRangePrefab;
|
|
}
|
|
}
|
|
|
|
public getCreepPrefabByType(creepType: string) {
|
|
switch (creepType.toLowerCase()) {
|
|
case "melee":
|
|
return this.creepMeleePrefab;
|
|
|
|
case "range":
|
|
return this.creepRangePrefab;
|
|
}
|
|
}
|
|
|
|
public getSkillIconByName(skillName: string)
|
|
{
|
|
var index = Number(skillName.split('S')[1]) - 1;
|
|
return skillName.includes("AS") ? this.asIconPrefabs[index] : this.psIconPrefabs[index];
|
|
}
|
|
|
|
}
|
|
|