import { _decorator, instantiate, Prefab, resources, Sprite, SpriteAtlas, UITransform } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { smc } from "../common/SingletonModuleComp"; import { GameEvent } from "../common/config/GameEvent"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('MissionHomeComp') @ecs.register('MissionHome', false) export class MissionHomeComp extends CCComp { protected onLoad(): void { this.on(GameEvent.MissionEnd,this.mission_end,this) } /** 视图层逻辑代码分离演示 */ start() { this.home_active() } start_mission() { oops.message.dispatchEvent(GameEvent.MissionStart, {}) this.node.active=false; } mission_end(){ this.home_active() } home_active(){ this.uodate_data() this.node.active=true this.btn_func("","fight") oops.message.dispatchEvent(GameEvent.UpdateHero, {}) } uodate_data(){ smc.syncData() } btn_func(e:string,data:any){ console.log("[MissionHomeComp]:btn_func",e,data) let btns=this.node.getChildByName("btns") let shop =btns.getChildByName("shop") let heros =btns.getChildByName("heros") let fight =btns.getChildByName("fight") let skill =btns.getChildByName("skill") let set =btns.getChildByName("set") shop.getChildByName("act").active=false heros.getChildByName("act").active=false fight.getChildByName("act").active=false skill.getChildByName("act").active=false set.getChildByName("act").active=false this.node.getChildByName("shop").active=false // this.node.getChildByName("heros").active=false // this.node.getChildByName("fight").active=false // this.node.getChildByName("skill").active=false // this.node.getChildByName("set").active=false switch(data){ case "shop": this.node.getChildByName("shop").active=true shop.getChildByName("act").active=true break case "heros": heros.getChildByName("act").active=true break case "fight": fight.getChildByName("act").active=true break case "skill": skill.getChildByName("act").active=true break case "set": set.getChildByName("act").active=true break default: fight.getChildByName("act").active=true break } } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } }