import { _decorator, instantiate, Label ,Prefab,resources,Sprite,SpriteAtlas,v3} 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('VictoryComp') @ecs.register('Victory', false) export class VictoryComp extends CCComp { reward_lv:number=1 reward_num:number=2 /** 视图层逻辑代码分离演示 */ protected onLoad(): void { this.on(GameEvent.MissionStart,this.mission_start,this) this.on(GameEvent.FightEnd,this.fight_end,this) } onAdded(args: any) { } mission_start(){ this.hide() } fight_end(e:any,val:any){ this.node.getChildByName("score").getComponent(Label).string=smc.mission.score.toString() this.node.getChildByName("score_add").getComponent(Label).string=smc.vmdata.mission_data.score.toString() this.open() } victory_end(){ this.hide() oops.message.dispatchEvent(GameEvent.MissionEnd) } open(){ this.show() } show(){ this.node.setPosition(v3(0,640,0)) } hide(){ this.node.setPosition(v3(-1500,640,0)) } do_x10(){ this.clear_x1() } do_x1(){ this.clear_x1() } clear_x1(){ this.victory_end() } item_show(e:any,val:any){ console.log("item_show",val) } protected onDestroy(): void { console.log("释放胜利界面"); } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy() } }