69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
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
|
|
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<monsters.length;i++){
|
|
monsters[i].MonView.ent.destroy()
|
|
}
|
|
for(let i=0;i<heros.length;i++){
|
|
heros[i].HeroView.ent.destroy()
|
|
}
|
|
for(let i=0;i<roles.length;i++){
|
|
roles[i].RoleView.ent.destroy()
|
|
}
|
|
for(let i=0;i<boss.length;i++){
|
|
boss[i].BossView.ent.destroy()
|
|
}
|
|
}
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
} |