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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { smc } from "../common/SingletonModuleComp"; import { MonViewComp } from "../mon/MonViewComp"; import { HeroViewComp } from "../hero/HeroViewComp"; import { RoleViewComp } from "../Role/RoleViewComp"; import { BossViewComp } from "../Boss/BossViewComp"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('VictoryComp') @ecs.register('Victory', false) export class VictoryComp extends CCComp { /** 视图层逻辑代码分离演示 */ start() { // console.log("VictoryComp start") oops.message.on("minssion_victory", this.do_victiry, this); oops.message.on("minssion_defeat", this.do_defeat, this); } private do_victiry() { smc.vm_data.mission.play=false if(smc.vm_data.role.mission%10==0){ smc.vm_data.role.mission_finish == true }else{ smc.vm_data.role.mission += 1 } this.node.getChildByName("Node").active = true; this.node.getChildByName("Node").getChildByName("defeat").active = false this.node.getChildByName("Node").getChildByName("victory").active = true; } private do_defeat() { smc.vm_data.mission.play=false this.node.getChildByName("Node").active = true; this.node.getChildByName("Node").getChildByName("victory").active = false; this.node.getChildByName("Node").getChildByName("defeat").active = true } end_mission(){ this.node.getChildByName("Node").active=false smc.vm_data.role.gold += smc.vm_data.mission.reward_gold smc.vm_data.role.exp += smc.vm_data.mission.reward_exp smc.vm_data.mission.reward_gold=0 smc.vm_data.mission.reward_exp=0 this.empty_mission() oops.message.dispatchEvent("to_mission") console.log("end_mission") } empty_mission(){ let monsters:any= ecs.query(ecs.allOf(MonViewComp)); let heros:any= ecs.query(ecs.allOf(HeroViewComp)); let roles:any= ecs.query(ecs.allOf(RoleViewComp)); let boss:any= ecs.query(ecs.allOf(BossViewComp)); for(let i=0;i