import { _decorator, Label } 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 { HeroViewComp } from "../hero/HeroViewComp"; import { BossViewComp } from "../Boss/BossViewComp"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; import { MissionReward } from "../common/config/MissionSet"; import { Items } from "../common/config/Items"; import { Item } from "./Item"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('VictoryComp') @ecs.register('Victory', false) export class VictoryComp extends CCComp { reward_lv:number=1 reward_num:number=2 rerawd_item:any={} if_show:boolean=false /** 视图层逻辑代码分离演示 */ start() { } private do_victiry() { if(this.if_show) return this.node.getChildByName("Node").setScale(1,1,1) this.getReward(true) this.node.getChildByName("Node").getChildByName("defeat").active = false this.node.getChildByName("Node").getChildByName("victory").active = true; } private do_defeat() { if(this.if_show) return this.node.getChildByName("Node").setScale(1,1,1) this.getReward(false) this.node.getChildByName("Node").getChildByName("victory").active = false; this.node.getChildByName("Node").getChildByName("defeat").active = true } getReward(is_victory:boolean){ let conut =2 if(is_victory) conut=1 let item1=ecs.getEntity(Item) let gold: number = Math.floor(RandomManager.instance.getRandomInt((3000 + smc.vmdata.mission.lv * 100) / 3 * 2, 3000 + smc.vmdata.mission.lv * 100)); let parent = this.node.getChildByName("Node").getChildByName("items") item1.load(1001,gold,parent) for (let i = 0; i < conut; i++) { let item=ecs.getEntity(Item) let reward:any = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], 1); let im =Items[reward[0]] item.load(im.uuid,im.r_num,parent) } this.if_show=true } end_mission(){ this.node.getChildByName("Node").setScale(0,0,0) this.if_show=false } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } }