62 lines
2.8 KiB
TypeScript
62 lines
2.8 KiB
TypeScript
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 { MonViewComp } from "../mon/MonViewComp";
|
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
|
import { RoleViewComp } from "../Role/RoleViewComp";
|
|
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";
|
|
|
|
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={}
|
|
/** 视图层逻辑代码分离演示 */
|
|
start() {
|
|
}
|
|
private do_victiry() {
|
|
this.node.getChildByName("Node").active = true;
|
|
this.getReward()
|
|
this.node.getChildByName("Node").getChildByName("defeat").active = false
|
|
this.node.getChildByName("Node").getChildByName("victory").active = true;
|
|
}
|
|
private do_defeat() {
|
|
this.node.getChildByName("Node").active = true;
|
|
this.getReward()
|
|
this.node.getChildByName("Node").getChildByName("victory").active = false;
|
|
this.node.getChildByName("Node").getChildByName("defeat").active = true
|
|
}
|
|
getReward(){
|
|
let reward1:any = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], 1);
|
|
let reward2:any = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], 1);
|
|
let item1 =Items[reward1[0]]
|
|
let item2 =Items[reward2[1]]
|
|
let r1_num=0
|
|
let r2_num=0
|
|
console.log("getReward:",item1,item2)
|
|
this.node.getChildByName("Node").getChildByName("item2").getChildByName("num").getComponent(Label).string=item1.r_num.toString()
|
|
this.node.getChildByName("Node").getChildByName("item2").getChildByName("name").getComponent(Label).string=item1.name.toString()
|
|
this.node.getChildByName("Node").getChildByName("item3").getChildByName("num").getComponent(Label).string=item2.r_num.toString()
|
|
this.node.getChildByName("Node").getChildByName("item3").getChildByName("name").getComponent(Label).string=item2.r_num.toString()
|
|
|
|
|
|
}
|
|
end_mission(){
|
|
this.node.getChildByName("Node").active=false
|
|
}
|
|
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
} |