44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { MSCardComp } from "./MSCardComp";
|
|
import { SkillSet } from "../common/config/SkillSet";
|
|
|
|
/** MSCard 模块 */
|
|
@ecs.register(`MSCard`)
|
|
export class MSCard extends ecs.Entity {
|
|
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
// this.addComponents<ecs.Comp>();
|
|
}
|
|
load(uuid:number=1001,parent:any,zone:number=0) {
|
|
var path = "game/gui/MSCard";
|
|
var icon_path = "game/heros/cards"
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
console.log("load_hcard",prefab)
|
|
var node = instantiate(prefab);
|
|
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = node.getChildByName("icon").getComponent(Sprite);
|
|
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
|
|
});
|
|
|
|
node.getChildByName("name").getComponent(Label).string = SkillSet[uuid].name
|
|
|
|
node.parent = parent
|
|
var msc = node.getComponent(MSCardComp)!;
|
|
msc.s_uuid= uuid
|
|
msc.update_data()
|
|
if(zone==1) {msc.is_update=true }else{msc.is_update=false}
|
|
if(zone==2) {msc.is_select=true}else{msc.is_select=false}
|
|
this.add(msc)
|
|
}
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
super.destroy();
|
|
}
|
|
}
|
|
|