奖励已经双倍奖励

This commit is contained in:
2025-08-19 19:40:34 +08:00
parent 22f35893d7
commit 854affeaae
32 changed files with 12848 additions and 7746 deletions

View File

@@ -1,9 +1,10 @@
import { _decorator, instantiate, Label ,Prefab,resources,Sprite,SpriteAtlas,v3} from "cc";
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 { ItemComp } from "./ItemComp";
const { ccclass, property } = _decorator;
@@ -14,13 +15,18 @@ export class VictoryComp extends CCComp {
reward_lv:number=1
reward_num:number=2
rewards:any[]=[]
/** 视图层逻辑代码分离演示 */
protected onLoad(): void {
}
onAdded(args: any) {
console.log("[VictoryComp] onAdded",args)
console.log("[VictoryComp] onAdded",args,smc.items)
if(args.rewards){
this.add_reward(args.rewards)
this.rewards=args.rewards
}
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
@@ -29,12 +35,39 @@ export class VictoryComp extends CCComp {
},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(){
oops.message.dispatchEvent(GameEvent.MissionEnd)
oops.gui.removeByNode(this.node)
}
//看广告双倍
watch_ad(){
return true
}
double_reward(){
if(this.watch_ad()){
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)
}
restart(){
oops.message.dispatchEvent(GameEvent.MissionStart)
oops.gui.removeByNode(this.node)