商店商品++
This commit is contained in:
@@ -41,21 +41,23 @@ export class GoodsComp extends Component {
|
||||
}
|
||||
private update_btn( ){
|
||||
if(smc.shop.goods_count[this.goods_count_key]<=0){
|
||||
this.node.getChildByName("ad").active=false
|
||||
this.node.getChildByName("free").active=false
|
||||
this.node.getChildByName("cast").active=false
|
||||
this.node.getChildByName("nothing").active=true
|
||||
this.node.getChildByName("btn").getChildByName("ad").active=false
|
||||
this.node.getChildByName("btn").getChildByName("free").active=false
|
||||
this.node.getChildByName("btn").getChildByName("diamond").active=false
|
||||
this.node.getChildByName("btn").getChildByName("gold").active=false
|
||||
this.node.getChildByName("btn").getChildByName("nothing").active=true
|
||||
this.node.getChildByName("btn").getComponent(Sprite).grayscale=true
|
||||
return
|
||||
}
|
||||
this.node.getChildByName("nothing").active=false
|
||||
this.node.getChildByName("btn").getChildByName("nothing").active=false
|
||||
this.node.getChildByName("btn").getComponent(Sprite).grayscale=false
|
||||
this.node.getChildByName("ad").active=this.goodsData.c_type==CType.AD
|
||||
this.node.getChildByName("free").active=this.goodsData.c_type==CType.FREE
|
||||
this.node.getChildByName("cast").active=this.goodsData.c_type==(CType.DIAMOND||CType.GOLD)
|
||||
this.node.getChildByName("cast").getChildByName("diamond").active=this.goodsData.c_type==CType.DIAMOND
|
||||
this.node.getChildByName("cast").getChildByName("gold").active=this.goodsData.c_type==CType.GOLD
|
||||
this.node.getChildByName("cast").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(this.goodsData.cast)
|
||||
this.node.getChildByName("btn").getChildByName("ad").active=this.goodsData.c_type==CType.AD
|
||||
this.node.getChildByName("btn").getChildByName("free").active=this.goodsData.c_type==CType.FREE
|
||||
this.node.getChildByName("btn").getChildByName("diamond").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(this.goodsData.cast)
|
||||
this.node.getChildByName("btn").getChildByName("gold").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(this.goodsData.cast)
|
||||
this.node.getChildByName("btn").getChildByName("diamond").active=this.goodsData.c_type==CType.DIAMOND
|
||||
this.node.getChildByName("btn").getChildByName("gold").active=this.goodsData.c_type==CType.GOLD
|
||||
|
||||
}
|
||||
/**
|
||||
* 更新图标
|
||||
|
||||
@@ -71,7 +71,7 @@ export class HCardUICom extends Component {
|
||||
if(oops.gui.has(UIID.HeroSelect)) {
|
||||
this.check_in_slot(this.h_uuid)
|
||||
smc.setFightHero(this.slot,this.h_uuid,true)
|
||||
oops.message.dispatchEvent(GameEvent.UpdateHero)
|
||||
oops.message.dispatchEvent(GameEvent.UpdateFightHero)
|
||||
oops.gui.remove(UIID.HeroSelect)
|
||||
}
|
||||
break
|
||||
|
||||
@@ -19,11 +19,11 @@ export class HeroPageComp extends Component {
|
||||
let heros=getHeroList()
|
||||
console.log("[HeroPageComp]:update_heros",heros)
|
||||
let height= Math.ceil(heros.length/3)*315+30
|
||||
this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform).height=height
|
||||
this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform).setContentSize(720,height)
|
||||
console.log("[HeroPageComp]:UITransform height",this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform))
|
||||
this.clear_heros()
|
||||
for(let i=0;i<heros.length;i++){
|
||||
let hero=heros[i]
|
||||
console.log("[HeroPageComp]:hero",hero)
|
||||
if(hero){
|
||||
this.load_hero(hero)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export class HeroReadyCom extends Component {
|
||||
slot: number=0;
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
||||
oops.message.on(GameEvent.UpdateFightHero,this.update_hero,this)
|
||||
}
|
||||
start() {
|
||||
this.update_hero()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
|
||||
import { _decorator, Component, instantiate, Node, Prefab, UITransform, Vec3 } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
@@ -22,8 +22,9 @@ export class HeroSelectCom extends Component {
|
||||
}
|
||||
update_heros(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
console.log("[HeroPageComp]:update_heros",heros)
|
||||
let width= heros.length*235+30
|
||||
let width= heros.length*230+20
|
||||
this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform).setContentSize(width,320)
|
||||
console.log("[HeroPageComp]:UITransform width",this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform))
|
||||
for(let i=0;i<heros.length;i++){
|
||||
let hero=heros[i]
|
||||
console.log("[HeroPageComp]:hero",hero)
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { GoodsComp } from './GoodsComp';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { getRandomGoods } from '../common/config/Goods';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ShopPageComp')
|
||||
export class ShopPageComp extends Component {
|
||||
daily_goods:any[]=[1001,1002,1004,1006]
|
||||
weekly_goods:any[]=[]
|
||||
monthly_goods:any[]=[]
|
||||
special_goods:any[]=[]
|
||||
daily:any[]=[]
|
||||
weekly:any[]=[]
|
||||
monthly:any[]=[]
|
||||
special:any[]=[]
|
||||
start() {
|
||||
this.update_daily_goods()
|
||||
this.update_daily()
|
||||
this.update_weekly()
|
||||
}
|
||||
update_daily_goods(){
|
||||
update_daily(){
|
||||
let items=this.node.getChildByName("daily").getChildByName("items").children
|
||||
for(let i=0;i<items.length;i++){
|
||||
let goods=items[i]
|
||||
goods.getComponent(GoodsComp).update_data(this.daily_goods[i],i)
|
||||
goods.getComponent(GoodsComp).update_data(smc.shop.daily[i],i)
|
||||
}
|
||||
}
|
||||
update_weekly(){
|
||||
if(smc.shop.weekly.length ==0) {
|
||||
this.weekly=getRandomGoods()
|
||||
}
|
||||
smc.shop.weekly=this.weekly
|
||||
let items=this.node.getChildByName("weekly").getChildByName("items").children
|
||||
for(let i=0;i<items.length;i++){
|
||||
let goods=items[i]
|
||||
goods.getComponent(GoodsComp).update_data(smc.shop.weekly[i],i+4)
|
||||
}
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
Reference in New Issue
Block a user