This commit is contained in:
2024-12-20 13:44:33 +08:00
parent 9798040635
commit 330f8da3da
2 changed files with 67 additions and 15 deletions

View File

@@ -1,14 +1,13 @@
export const BoxDrop={ export const BoxDrop={
1:[ 1:[
{uuid: 9001,dropRate: 10,num_max: 10,type:0}, {uuid: 1009,dropRate: 10,num_max: 10,type:0},
{uuid: 9002,dropRate: 10,num_max: 10,type:0}, {uuid: 1010,dropRate: 10,num_max: 10,type:0},
{uuid: 9003,dropRate: 10,num_max: 10,type:0}, {uuid: 1011,dropRate: 10,num_max: 10,type:0},
], ],
2:[ 2:[
{uuid: 9001,dropRate: 10,num_max: 10,type:0}, {uuid: 1001,dropRate: 10,num_max: 10,type:0},
{uuid: 9002,dropRate: 10,num_max: 10,type:0}, {uuid: 1002,dropRate: 10,num_max: 10,type:0},
{uuid: 9003,dropRate: 10,num_max: 10,type:0},
], ],
3:[ 3:[

View File

@@ -8,6 +8,7 @@ import { Items } from "../common/config/Items";
import { HChipComp } from "../hero/HChipComp"; import { HChipComp } from "../hero/HChipComp";
import { BoxDrop } from "../common/config/RewardSet"; import { BoxDrop } from "../common/config/RewardSet";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
import { SChipComp } from "../hero/SChipComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -56,7 +57,6 @@ export class LuckHomeCompComp extends CCComp {
if(smc.items[1001].num > 0){ if(smc.items[1001].num > 0){
this.btnno.active = false; this.btnno.active = false;
this.selected="sb" this.selected="sb"
}else{ }else{
this.btnno.active = true this.btnno.active = true
} }
@@ -112,14 +112,14 @@ export class LuckHomeCompComp extends CCComp {
} }
get_reward(reward:number){ get_reward(reward:number){
let list =BoxDrop[reward]; let list =BoxDrop[reward];
let chip_uuid= 0 let uuid= 0
let num =1 let num =1
let i=0 let i=0
while (chip_uuid==0) { while (uuid==0) {
for (let x = 0; x < list.length; x++) { for (let x = 0; x < list.length; x++) {
let rate = Math.random()*100 let rate = Math.random()*100
if(rate < list[x].dropRate){ 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); num =RandomManager.instance.getRandomInt(list[x].num_max/2,list[x].num_max);
break; break;
} }
@@ -128,17 +128,18 @@ export class LuckHomeCompComp extends CCComp {
} }
switch(reward){ switch(reward){
case 3: case 3:
this.show_hero_chip(chip_uuid,num) this.show_hero_chip(uuid,num)
smc.heros[chip_uuid].num += num smc.heros[uuid].num += num
break; break;
case 2: case 2:
smc.heros[1005].num += num this.show_skill_chip(uuid,num)
smc.skills[uuid].num += num
break; break;
case 1: case 1:
smc.heros[1006].num += num this.show_item(uuid,num)
smc.items[uuid].num += num
break; break;
} }
} }
show_hero_chip(uuid:number,num:number){ show_hero_chip(uuid:number,num:number){
let path = "game/gui/hchip"; let path = "game/gui/hchip";
@@ -153,6 +154,58 @@ export class LuckHomeCompComp extends CCComp {
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
node.destroy(); node.destroy();
}, 10) }, 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() { show_bbox() {
var parent = this.node.getChildByName("bbox") var parent = this.node.getChildByName("bbox")