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

This commit is contained in:
panw
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
}

View File

@@ -25,7 +25,7 @@ export class HeroHomeComp extends CCComp {
start() {
// this.load_talents()
console.log("hero_home start")
this.h_uuid=9001
this.h_uuid=5001
this.hero_show(this.h_uuid)
this.loads()
}
@@ -44,6 +44,7 @@ export class HeroHomeComp extends CCComp {
this.h_uuid=uuid
this.role=smc.heros[uuid]
this.hero=HeroInfo[uuid]
console.log("hero_show",uuid)
let tal=this.node.getChildByName("sk").getChildByName("tal");
let sk_node= this.node.getChildByName("sk");
let skill1 = SkillSet[this.hero.sk1[0]]

View File

@@ -18,7 +18,6 @@ export class MSkillComp extends CCComp {
cd:number = 0;
/** 视图层逻辑代码分离演示 */
start() {
console.log("MSkillComp start s_uuid:",this.s_uuid,this.group);
}
init(){
this.lv=0

View File

@@ -91,7 +91,6 @@ export class MissionHomeComp extends CCComp {
for(let i=0;i<loaded.length;i++){
if(smc.heros[loaded[i].HeroSelectComp.h_uuid].slv ==0 ) {
loaded[i].HeroSelectComp.node.active=false
console.log("loaded[i].HeroSelectComp",loaded[i].HeroSelectComp)
}else{
loaded[i].HeroSelectComp.node.active=true
}
@@ -138,13 +137,13 @@ export class MissionHomeComp extends CCComp {
}
}
call_hero(h_uuid:number,index:number){
console.log("call hero",h_uuid,HeroInfo[h_uuid])
var path = "game/heros/uiheros/"+HeroInfo[h_uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!
node.setPosition(this.heros_pos[index].px,BoxSet.GAME_LINE,0);
console.log("this.heros_pos[index].px",this.heros_pos[index].px)
let comp = node.getComponent(UiHeroComp)
comp.h_uuid = h_uuid
this.heros.push(comp)