掉落加双倍处理 基本完成

This commit is contained in:
panfudan
2025-08-19 23:22:59 +08:00
parent c47ecc21e6
commit bee97b4fe8
6 changed files with 4496 additions and 4730 deletions

View File

@@ -16,6 +16,11 @@ 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 {
@@ -23,6 +28,9 @@ export class VictoryComp extends CCComp {
onAdded(args: any) {
console.log("[VictoryComp] onAdded",args,smc.items)
if(args.game_data){
this.game_data=args.game_data
}
if(args.rewards){
this.add_reward(args.rewards)
this.rewards=args.rewards
@@ -52,15 +60,28 @@ export class VictoryComp extends CCComp {
}
}
victory_end(){
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionEnd)
oops.gui.removeByNode(this.node)
}
clear_data(){
this.game_data={
exp:0,
gold:0,
diamond:0
}
this.rewards=[]
this.node.getChildByName("box").getChildByName("items").removeAllChildren()
}
//看广告双倍
watch_ad(){
return true
}
double_reward(){
if(this.watch_ad()){
smc.addExp(this.game_data["exp"])
smc.addGold(this.game_data["gold"])
smc.addDiamond(this.game_data["diamond"])
this.rewards.forEach(d_item=>{
smc.addItem(d_item.item_uuid,d_item.count)
})
@@ -69,6 +90,7 @@ export class VictoryComp extends CCComp {
console.log("[VictoryComp]double_reward",smc.items,this.rewards)
}
restart(){
this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionStart)
oops.gui.removeByNode(this.node)
}