dd
This commit is contained in:
@@ -9,6 +9,7 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { RewardComp } from "./RewardComp";
|
||||
import { SChipComp } from "../hero/SChipComp";
|
||||
import { HChipComp } from "../hero/HChipComp";
|
||||
import { Goods } from "./Goods";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -21,133 +22,13 @@ export class ShopHomeComp extends CCComp {
|
||||
this.get_items();
|
||||
}
|
||||
get_items(){
|
||||
|
||||
let goods = this.node.getChildByName("goods").getChildByName("view").getChildByName("content")
|
||||
goods.getComponent(UITransform).height=5*200
|
||||
let goodsnode = this.node.getChildByName("goods").getChildByName("view").getChildByName("content")
|
||||
goodsnode.getComponent(UITransform).height=Math.floor(smc.goods.length/4*240)+50
|
||||
console.log("smc.goods",smc.goods)
|
||||
let free = goods.getChildByName("free").getChildByName("items");
|
||||
let goods1 = goods.getChildByName("goods1").getChildByName("items");
|
||||
let herochips = goods.getChildByName("herochips").getChildByName("items");
|
||||
let skillchips = goods.getChildByName("skillchips").getChildByName("items");
|
||||
for (let x = 0; x < smc.goods.free.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.free[x].uuid,smc.goods.free[x].num,free)
|
||||
for (let x = 0; x < smc.goods.length; x++) {
|
||||
let goods=ecs.getEntity<Goods>(Goods)
|
||||
goods.load(x,goodsnode)
|
||||
}
|
||||
for (let x = 0; x < smc.goods.goods1.length; x++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
item.load(smc.goods.goods1[x].uuid,smc.goods.goods1[x].num,goods1)
|
||||
}
|
||||
for (let x = 0; x < smc.goods.herochips.length; x++) {
|
||||
let path = "game/gui/hchip";
|
||||
let prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
let node = instantiate(prefab);
|
||||
node.parent=herochips
|
||||
let hc= node.getComponent(HChipComp)
|
||||
hc.update_data(smc.goods.herochips[x].uuid,smc.goods.herochips[x].num)
|
||||
}
|
||||
|
||||
for (let x = 0; x < smc.goods.skillchips.length; x++) {
|
||||
let path = "game/gui/schip";
|
||||
let prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
let node = instantiate(prefab);
|
||||
node.parent=skillchips
|
||||
let sc= node.getComponent(SChipComp)
|
||||
sc.update_data(smc.goods.skillchips[x].uuid,smc.goods.skillchips[x].num)
|
||||
}
|
||||
// for (let x = 0; x < smc.goods.goods4.length; x++) {
|
||||
// let item=ecs.getEntity<Item>(Item)
|
||||
// item.load(smc.goods.goods4[x].uuid,smc.goods.goods4[x].num,goods4)
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
item_show(e:any,val:any){
|
||||
oops.gui.open(UIID.ItemInfo, {uuid:val,type:0});
|
||||
}
|
||||
get_free(){
|
||||
console.log("免费领取")
|
||||
if(smc.vmdata.free.buy <= 0){
|
||||
oops.gui.toast("今日领取次数已用完");
|
||||
return
|
||||
}
|
||||
for (let x = 0; x < smc.goods.free.length; x++) {
|
||||
if(smc.goods.free[x].uuid ==9001){
|
||||
smc.vmdata.gold.num+=smc.goods.free[x].num
|
||||
}
|
||||
if(smc.goods.free[x].uuid ==9003){
|
||||
smc.vmdata.exp.num+=smc.goods.free[x].num
|
||||
}
|
||||
if(smc.goods.free[x].uuid < 9000){
|
||||
smc.items[smc.goods.free[x].uuid].num+=smc.goods.free[x].num
|
||||
}
|
||||
}
|
||||
smc.vmdata.free.buy--
|
||||
}
|
||||
get_goods1(){
|
||||
console.log("购买商品1")
|
||||
if(smc.vmdata.goods1.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
if(smc.vmdata.gold.num < smc.vmdata.goods1.cost){
|
||||
oops.gui.toast("金币不足");
|
||||
return
|
||||
}
|
||||
for (let x = 0; x < smc.goods.goods1.length; x++) {
|
||||
if(smc.goods.goods1[x].uuid ==9001){
|
||||
smc.vmdata.gold.num+=smc.goods.goods1[x].num
|
||||
}
|
||||
if(smc.goods.goods1[x].uuid ==9003){
|
||||
smc.vmdata.exp.num+=smc.goods.goods1[x].num
|
||||
}
|
||||
if(smc.goods.goods1[x].uuid < 9000){
|
||||
smc.items[smc.goods.goods1[x].uuid].num+=smc.goods.goods1[x].num
|
||||
}
|
||||
}
|
||||
smc.vmdata.goods1.buy--
|
||||
smc.vmdata.gold.num-=smc.vmdata.goods1.cost
|
||||
}
|
||||
get_goods2(){
|
||||
console.log("购买商品2")
|
||||
if(smc.vmdata.herochips.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
if(smc.vmdata.gold.num < smc.vmdata.herochips.cost){
|
||||
oops.gui.toast("金币不足");
|
||||
return
|
||||
}
|
||||
for (let x = 0; x < smc.goods.herochips.length; x++) {
|
||||
smc.heros[smc.goods.herochips[x].uuid].num += smc.goods.herochips[x].num
|
||||
}
|
||||
smc.vmdata.herochips.buy--
|
||||
smc.vmdata.gold.num-=smc.vmdata.herochips.cost
|
||||
}
|
||||
|
||||
get_goods3(){
|
||||
console.log("购买商品3")
|
||||
if(smc.vmdata.skillchips.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
if(smc.vmdata.gold.num < smc.vmdata.skillchips.cost){
|
||||
oops.gui.toast("金币不足");
|
||||
return
|
||||
}
|
||||
for (let x = 0; x < smc.goods.skillchips.length; x++) {
|
||||
smc.skills[smc.goods.skillchips[x].uuid].num += smc.goods.skillchips[x].num
|
||||
}
|
||||
smc.vmdata.skillchips.buy--
|
||||
smc.vmdata.gold.num-=smc.vmdata.skillchips.cost
|
||||
|
||||
}
|
||||
get_goods4(){
|
||||
console.log("购买商品4")
|
||||
if(smc.vmdata.goods4.buy <= 0){
|
||||
oops.gui.toast("今日购买次数已用完");
|
||||
return
|
||||
}
|
||||
smc.vmdata.goods4.buy--
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user