diff --git a/assets/script/game/common/config/RewardSet.ts b/assets/script/game/common/config/RewardSet.ts index 9bf56ac3..8945566c 100644 --- a/assets/script/game/common/config/RewardSet.ts +++ b/assets/script/game/common/config/RewardSet.ts @@ -1,14 +1,13 @@ export const BoxDrop={ 1:[ - {uuid: 9001,dropRate: 10,num_max: 10,type:0}, - {uuid: 9002,dropRate: 10,num_max: 10,type:0}, - {uuid: 9003,dropRate: 10,num_max: 10,type:0}, + {uuid: 1009,dropRate: 10,num_max: 10,type:0}, + {uuid: 1010,dropRate: 10,num_max: 10,type:0}, + {uuid: 1011,dropRate: 10,num_max: 10,type:0}, ], 2:[ - {uuid: 9001,dropRate: 10,num_max: 10,type:0}, - {uuid: 9002,dropRate: 10,num_max: 10,type:0}, - {uuid: 9003,dropRate: 10,num_max: 10,type:0}, + {uuid: 1001,dropRate: 10,num_max: 10,type:0}, + {uuid: 1002,dropRate: 10,num_max: 10,type:0}, ], 3:[ diff --git a/assets/script/game/map/LuckHomeComp.ts b/assets/script/game/map/LuckHomeComp.ts index b68a17af..2e0b4e38 100644 --- a/assets/script/game/map/LuckHomeComp.ts +++ b/assets/script/game/map/LuckHomeComp.ts @@ -8,6 +8,7 @@ import { Items } from "../common/config/Items"; import { HChipComp } from "../hero/HChipComp"; import { BoxDrop } from "../common/config/RewardSet"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; +import { SChipComp } from "../hero/SChipComp"; const { ccclass, property } = _decorator; @@ -56,7 +57,6 @@ export class LuckHomeCompComp extends CCComp { if(smc.items[1001].num > 0){ this.btnno.active = false; this.selected="sb" - }else{ this.btnno.active = true } @@ -112,14 +112,14 @@ export class LuckHomeCompComp extends CCComp { } get_reward(reward:number){ let list =BoxDrop[reward]; - let chip_uuid= 0 + let uuid= 0 let num =1 let i=0 - while (chip_uuid==0) { + while (uuid==0) { for (let x = 0; x < list.length; x++) { let rate = Math.random()*100 if(rate < list[x].dropRate){ - chip_uuid=list[x].uuid; + uuid=list[x].uuid; num =RandomManager.instance.getRandomInt(list[x].num_max/2,list[x].num_max); break; } @@ -128,17 +128,18 @@ export class LuckHomeCompComp extends CCComp { } switch(reward){ case 3: - this.show_hero_chip(chip_uuid,num) - smc.heros[chip_uuid].num += num + this.show_hero_chip(uuid,num) + smc.heros[uuid].num += num break; case 2: - smc.heros[1005].num += num + this.show_skill_chip(uuid,num) + smc.skills[uuid].num += num break; case 1: - smc.heros[1006].num += num + this.show_item(uuid,num) + smc.items[uuid].num += num break; } - } show_hero_chip(uuid:number,num:number){ let path = "game/gui/hchip"; @@ -153,6 +154,58 @@ export class LuckHomeCompComp extends CCComp { this.scheduleOnce(()=>{ node.destroy(); }, 10) + + } + show_item(uuid:number,num:number){ + var path = "game/gui/item"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.getChildByName("num").getComponent(Label).string = num.toString(); + if(num==0){ + node.getChildByName("num").getComponent(Label).string =""; + } + + let url = "gui/items"; + let pathName= Items[uuid].path; + switch(Items[uuid].lv){ + case 1: + node.getChildByName("lv1").active = true; + break; + case 2: + node.getChildByName("lv2").active = true; + break; + case 3: + node.getChildByName("lv3").active = true; + break; + case 4: + node.getChildByName("lv4").active = true; + break; + } + resources.load(url, SpriteAtlas, (err: any, atlas) => { + const sprite = node.getChildByName("icon").getComponent(Sprite); + sprite.spriteFrame = atlas.getSpriteFrame(pathName); + }); + node.parent = this.node.getChildByName("bbox"); + this.scheduleOnce(()=>{ + node.parent = this.node.getChildByName("items"); + }, 0.5) + this.scheduleOnce(()=>{ + node.destroy(); + }, 10) + } + show_skill_chip(uuid:number,num:number){ + let path = "game/gui/schip"; + let prefab: Prefab = oops.res.get(path, Prefab)!; + let node = instantiate(prefab); + let sc= node.getComponent(SChipComp) + sc.update_data(uuid,num) + node.parent = this.node.getChildByName("bbox"); + this.scheduleOnce(()=>{ + node.parent = this.node.getChildByName("items"); + }, 0.5) + this.scheduleOnce(()=>{ + node.destroy(); + }, 10) } show_bbox() { var parent = this.node.getChildByName("bbox")