商品页完成+ 英雄uuid 5000起步,技能6000起步,物品1000起步,金币9001

This commit is contained in:
2024-12-24 15:41:52 +08:00
parent ca54b0a3da
commit 228112b4ed
17 changed files with 4219 additions and 4154 deletions

View File

@@ -27,13 +27,13 @@ export class GoodsComp extends CCComp {
let goods:any=smc.goods[this.smc_index]
let gnode=this.node.getChildByName("item")
switch (goods.type) {
case 0:
default:
let item=ecs.getEntity<Item>(Item)
item.load(goods.uuid,goods.num,gnode)
this.node.getChildByName("inventory").getComponent(Label).string="库存:"+goods.inventory.toString()
console.log("item",item)
break;
case 1:
case 3:
let path = "game/gui/hchip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
@@ -51,7 +51,34 @@ export class GoodsComp extends CCComp {
}
buy(){
console.log("购买商品"+this.smc_index)
let goods:any=smc.goods[this.smc_index]
if(smc.vmdata.gold.num <= goods.cost){
oops.gui.toast("金币不足");
return
}
if(goods.inventory <= 0){
oops.gui.toast("库存不足");
return
}
switch (goods.type) {
case 0:
smc.vmdata.gold.num+=goods.num
break;
case 1:
smc.vmdata.exp.num+=goods.num
break;
case 2:
smc.items[goods.uuid].num+=goods.num
break;
case 3:
smc.heros[goods.uuid].num += goods.num
break;
}
goods.inventory--
smc.vmdata.gold.num-=goods.cost
this.update_inventory()
}
update_inventory(){
this.node.getChildByName("inventory").getComponent(Label).string="库存:"+smc.goods[this.smc_index].inventory
}