奖励到账

This commit is contained in:
walkpan
2024-11-28 19:09:04 +08:00
parent a0cc46e0b2
commit bc0f77ed62
15 changed files with 456 additions and 992 deletions

View File

@@ -21,24 +21,18 @@ export class VictoryComp extends CCComp {
reward_lv:number=1
reward_num:number=2
rerawd_item:any={}
rewards:any=[]
if_show:boolean=false
/** 视图层逻辑代码分离演示 */
start() {
this.rewards=[]
}
private do_victiry() {
private do_victiry(is_victory:boolean) {
if(this.if_show) return
this.getReward(is_victory)
this.node.getChildByName("Node").getChildByName("defeat").active = is_victory
this.node.getChildByName("Node").getChildByName("victory").active = !is_victory;
this.node.setPosition(0,this.node.position.y,0)
this.getReward(true)
this.node.getChildByName("Node").getChildByName("defeat").active = false
this.node.getChildByName("Node").getChildByName("victory").active = true;
}
private do_defeat() {
if(this.if_show) return
this.node.setPosition(0,this.node.position.y,0)
this.getReward(false)
this.node.getChildByName("Node").getChildByName("victory").active = false;
this.node.getChildByName("Node").getChildByName("defeat").active = true
}
getReward(is_victory:boolean){
let conut =2
@@ -48,19 +42,42 @@ export class VictoryComp extends CCComp {
let parent = this.node.getChildByName("Node").getChildByName("items")
let reward:any = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], conut);
item1.load(9001,gold,parent)
this.rewards = [];
this.rewards[0]={uuid:9001,num:gold}
for (let i = 0; i < conut; i++) {
let item=ecs.getEntity<Item>(Item)
let im =Items[reward[i]]
while (Items[reward[i]]==undefined) {
let r = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], 1);
Items[reward[i]]=r[0]
console.log("getReward undefined",Items[reward[i]],i)
}
let im =Items[reward[i]]
item.load(im.uuid,im.r_num,parent)
this.rewards[i+1]={uuid:9001,num:gold}
}
this.if_show=true
}
do_x10(){
console.log("x10")
for (let i = 0; i < this.rewards.length; i++) {
if(this.rewards[i].uuid==9001){
smc.vmdata.role.gold+=this.rewards[i].num*10
}else{
smc.vmdata.items[this.rewards[i].uuid]+=this.rewards[i].num*10
}
}
console.log("do_x10",smc.vmdata)
this.end_mission()
}
do_x1(){
console.log("x1")
for (let i = 0; i < this.rewards.length; i++) {
if(this.rewards[i].uuid==9001){
smc.vmdata.role.gold+=this.rewards[i].num
}else{
smc.vmdata.items[this.rewards[i].uuid]+=this.rewards[i].num
}
}
console.log("x1",smc.vmdata)
this.end_mission()
}
end_mission(){