掉落加双倍处理 基本完成
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user