import { _decorator } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { HeroHomeComp } from "../map/HeroHomeComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('HeroCardComp') @ecs.register('HeroCardComp', false) export class HeroCardComp extends CCComp { @property(HeroHomeComp) hcc_home: HeroHomeComp = null!; hcc_uuid: number = 0; onLoad() { oops.message.on("hero_card_show_info", this.check_show, this); } /** 视图层逻辑代码分离演示 */ start() { this.hcc_home=this.node.parent.parent.parent.parent.getComponent(HeroHomeComp); // console.log("hero_card hcc_home",this.hcc_home) } show_info(){ this.hcc_home.hero_show(this.hcc_uuid) oops.message.dispatchEvent("hero_card_show_info",{uuid:this.hcc_uuid}) } check_show(event: string, args: any){ this.show_bg(false) if(args.uuid==this.hcc_uuid){ this.show_bg(true) } } show_bg(val:boolean){ this.node.getChildByName("show").active=val } /** 全局消息逻辑处理 */ // private onHandler(event: string, args: any) { // switch (event) { // case ModuleEvent.Cmd: // break; // } // } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } }