super-hero/assets/cc-game/scripts/global/GameAssets.ts

89 lines
2.6 KiB
TypeScript
Raw Normal View History

2024-05-08 04:03:33 -07:00
import { SpriteFrame } from 'cc';
import { Prefab } from 'cc';
import { SpriteAtlas } from 'cc';
import { _decorator, Component, Node } from 'cc';
2024-05-20 00:03:32 -07:00
import { GameDefine } from '../config/GameDefine';
2024-05-08 04:03:33 -07:00
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!;
2024-05-12 20:54:17 -07:00
@property(Prefab) creepMeleePrefab: Prefab = null!;
@property(Prefab) creepRangePrefab: Prefab = null!;
2024-05-08 04:03:33 -07:00
@property(Prefab) activeSkillPrefabs: Prefab[] = [];
@property(Prefab) bossMeleePrefab: Prefab = null!;
@property(Prefab) bossRangePrefab: Prefab = null!;
2024-05-12 20:54:17 -07:00
@property(Prefab) bossSlowPrefab: Prefab = null!;
2024-05-15 01:53:18 -07:00
@property(Prefab) psIconPrefabs: Prefab[] = [];
@property(Prefab) asIconPrefabs: Prefab[] = [];
2024-05-20 00:03:32 -07:00
@property(Prefab) rewardItemPrefabs: Prefab[] = [];
2024-05-29 19:24:12 -07:00
@property(Prefab) listGameObjectPrefabs: Prefab[] = [];
2024-06-04 21:28:00 -07:00
@property(Prefab) gatePortal: Prefab[] = [];
2024-05-08 04:03:33 -07:00
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;
}
}
2024-05-12 20:54:17 -07:00
public getCreepPrefabByType(creepType: string) {
switch (creepType.toLowerCase()) {
case "melee":
return this.creepMeleePrefab;
case "range":
return this.creepRangePrefab;
}
}
2024-05-15 01:53:18 -07:00
public getSkillIconByName(skillName: string)
{
var index = Number(skillName.split('S')[1]) - 1;
return skillName.includes("AS") ? this.asIconPrefabs[index] : this.psIconPrefabs[index];
}
2024-05-20 00:03:32 -07:00
public getRewardItemPrefab(rewardName: string)
{
switch (rewardName) {
case GameDefine.REWARD_TYPE.GOLD:
return this.rewardItemPrefabs[0];
2024-05-29 19:24:12 -07:00
case GameDefine.REWARD_TYPE.KEY:
2024-05-20 00:03:32 -07:00
return this.rewardItemPrefabs[1];
2024-05-29 19:24:12 -07:00
case GameDefine.REWARD_TYPE.ENERGY:
2024-05-20 00:03:32 -07:00
return this.rewardItemPrefabs[2];
default:
return null;
}
}
2024-05-29 19:24:12 -07:00
public getGameObjectPrefabByNo(objectNo: number) {
return this.listGameObjectPrefabs[objectNo - 1];
}
2024-05-08 04:03:33 -07:00
}