清理掉一些错误, 重新开始设计

This commit is contained in:
2025-10-12 22:39:10 +08:00
parent 797cf72a09
commit a1a5c37ad0

View File

@@ -33,72 +33,27 @@ export class VictoryComp extends CCComp {
if(args.game_data){ if(args.game_data){
this.game_data=args.game_data this.game_data=args.game_data
} }
if(args.rewards){ this.node.getChildByName("title").getChildByName("victory").active=true
this.add_reward(args.rewards)
this.rewards=args.rewards
}
this.node.getChildByName("box").getChildByName("items").getChildByName("exp").getChildByName("num").getComponent(Label)!.string="x"+this.game_data["exp"].toString()
this.node.getChildByName("box").getChildByName("items").getChildByName("gold").getChildByName("num").getComponent(Label)!.string="x"+this.game_data["gold"].toString()
this.node.getChildByName("box").getChildByName("items").getChildByName("diamond").getChildByName("num").getComponent(Label)!.string="x"+this.game_data["diamond"].toString()
this.node.getChildByName("title").getChildByName("victory").active=args.victory
this.node.getChildByName("title").getChildByName("defeat").active=!args.victory
this.node.getChildByName("btns").getChildByName("next").active=false this.node.getChildByName("btns").getChildByName("next").active=false
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.node.getChildByName("btns").getChildByName("next").active=true this.node.getChildByName("btns").getChildByName("next").active=true
},0.2) },0.2)
} }
add_reward(rewards:any[]){
let parent=this.node.getChildByName("box").getChildByName("items")
let items=parent.children
for(let i=0;i<rewards.length;i++){
let d_item=rewards[i]
let path="game/gui/item"
const prefab = oops.res.get(path, Prefab);
if (!prefab) {
console.error("[MissionComp=>do_drop] 预制体加载失败:", path);
return;
}
const node = instantiate(prefab) as unknown as Node;
node.parent=parent
node.getComponent(ItemComp)!.update_data(d_item.item_uuid,d_item.count,{no_show:true})
}
}
victory_end(){ victory_end(){
this.clear_data() this.clear_data()
oops.message.dispatchEvent(GameEvent.MissionEnd) oops.message.dispatchEvent(GameEvent.MissionEnd)
oops.gui.removeByNode(this.node) oops.gui.removeByNode(this.node)
} }
clear_data(){ clear_data(){
this.game_data={
exp:0,
gold:0,
diamond:0
}
this.rewards=[]
let items=this.node.getChildByName("box").getChildByName("items")
items.children.forEach(element => {
if(element.name=="exp"||element.name=="gold"||element.name=="diamond"){
element.getChildByName("num").getComponent(Label)!.string="0"
}else{
element.destroy()
}
});
} }
//看广告双倍 //看广告双倍
watch_ad(){ watch_ad(){
return true return true
} }
double_reward(){ 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)
})
this.node.getChildByName("btns").getChildByName("double").active=false
}
// console.log("[VictoryComp]double_reward",smc.items,this.rewards) // console.log("[VictoryComp]double_reward",smc.items,this.rewards)
} }
restart(){ restart(){
@@ -106,7 +61,6 @@ export class VictoryComp extends CCComp {
oops.message.dispatchEvent(GameEvent.MissionStart) oops.message.dispatchEvent(GameEvent.MissionStart)
oops.gui.removeByNode(this.node) oops.gui.removeByNode(this.node)
} }
item_show(e:any,val:any){ item_show(e:any,val:any){
// console.log("item_show",val) // console.log("item_show",val)
} }