Files
heros/assets/script/game/map/VictoryComp.ts

73 lines
2.1 KiB
TypeScript

import { _decorator, instantiate, Label ,Prefab,Node} 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";
import { it } from "node:test";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('VictoryComp')
@ecs.register('Victory', false)
export class VictoryComp extends CCComp {
reward_lv:number=1
reward_num:number=2
rewards:any[]=[]
game_data:any={
exp:0,
gold:0,
diamond:0
}
/** 视图层逻辑代码分离演示 */
protected onLoad(): void {
}
onAdded(args: any) {
// console.log("[VictoryComp] onAdded",args,smc.items)
if(args.game_data){
this.game_data=args.game_data
}
this.node.getChildByName("title").getChildByName("victory").active=true
this.node.getChildByName("btns").getChildByName("next").active=false
this.scheduleOnce(()=>{
this.node.getChildByName("btns").getChildByName("next").active=true
},0.2)
}
victory_end(){
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionEnd)
oops.gui.removeByNode(this.node)
}
clear_data(){
}
//看广告双倍
watch_ad(){
return true
}
double_reward(){
// console.log("[VictoryComp]double_reward",smc.items,this.rewards)
}
restart(){
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionStart)
oops.gui.removeByNode(this.node)
}
item_show(e:any,val:any){
// console.log("item_show",val)
}
protected onDestroy(): void {
// console.log("释放胜利界面");
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy()
}
}