完成开箱抽卡 和 怪物掉落设置

This commit is contained in:
2025-01-19 23:43:14 +08:00
parent cebf09a58c
commit d756516cc6
30 changed files with 51192 additions and 38040 deletions

View File

@@ -33,85 +33,42 @@ export class LuckHomeCompComp extends CCComp {
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
this.frist();
// this.frist();
}
frist(){
if(smc.items[1001].num > 0){this.select_box(null,"sb");}
else if(smc.items[1002].num > 0){this.select_box(null,"mb");}
else if(smc.items[1003].num > 0){this.select_box(null,"lb");}
this.check_num();
this.colse_reward()
}
check_num(){
this.sbn.getChildByName("num").getComponent(Label).string = smc.items[1001].num.toString();
this.mbn.getChildByName("num").getComponent(Label).string = smc.items[1002].num.toString();
this.lbn.getChildByName("num").getComponent(Label).string = smc.items[1003].num.toString();
}
select_box(e:any, val:string){
this.sbn.setScale(1,1,1);
this.mbn.setScale(1,1,1);
this.lbn.setScale(1,1,1);
switch(val){
case "sb":
this.sbn.setScale(1.2,1.2,1);
if(smc.items[1001].num > 0){
this.btnno.active = false;
this.selected="sb"
}else{
this.btnno.active = true
}
break;
case "mb":
this.mbn.setScale(1.2,1.2,1);
if(smc.items[1002].num > 0){
this.btnno.active = false;
this.selected="mb"
}else{
this.btnno.active = true
}
break;
case "lb":
this.lbn.setScale(1.2,1.2,1);
if(smc.items[1003].num > 0){
this.btnno.active = false;
this.selected="lb"
}else{
this.btnno.active = true
}
break;
default:
this.selected="";
break;
}
}
open_sb() {
smc.items[1001].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(1)
}, 0.5)
smc.vmdata.box.num--;
this.open_reward()
this.get_reward(1)
}
open_mb() {
smc.items[1002].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
if (smc.vmdata.box.num <=0) {oops.gui.toast("宝箱数量不足");return;}
smc.vmdata.box.num=smc.vmdata.box.num-5;
this.open_reward()
for (let x = 0; x < 5; x++) {
this.get_reward(2)
}, 0.5)
}
}
open_lb() {
smc.items[1003].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(3)
}, 0.5)
if (smc.vmdata.box.num <=0) {oops.gui.toast("宝箱数量不足");return;}
smc.vmdata.box.num=smc.vmdata.box.num-15;
this.open_reward()
for (let x = 0; x < 15; x++) {
this.get_reward(2)
}
}
colse_reward() {
this.node.getChildByName("reward").setScale(0,0,0);
this.node.getChildByName("reward").getChildByName("items").removeAllChildren();
}
open_reward() {
this.node.getChildByName("reward").setScale(1,1,1);
}
get_reward(reward:number){
console.log("get_reward",reward)
let list =BoxDrop[reward];
let uuid= 0
let num =1
@@ -156,53 +113,30 @@ export class LuckHomeCompComp extends CCComp {
}
}
show_hero_chip(uuid:number,num:number){
console.log("show_hero_chip",uuid,num)
let path = "game/gui/hchip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
node.setScale(2,2)
let hc= node.getComponent(HChipComp)
hc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_item(uuid:number,num:number){
var path = "game/gui/item";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setScale(2,2)
let ic= node.getComponent(ItemComp)
ic.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_skill_chip(uuid:number,num:number){
let path = "game/gui/schip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
node.setScale(2,2)
let sc= node.getComponent(SChipComp)
sc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_bbox() {
var parent = this.node.getChildByName("bbox")