商店商品++
This commit is contained in:
@@ -38,11 +38,12 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
exp:0,
|
||||
}
|
||||
shop:any={
|
||||
daily_goods:[],
|
||||
weekly_goods:[],
|
||||
monthly_goods:[],
|
||||
special_goods:[],
|
||||
goods_count:[1,3,1,3],
|
||||
daily:[1001,1004,1002,1005],
|
||||
weekly:[],
|
||||
monthly:[],
|
||||
special:[],
|
||||
goods_count:[1,1,3,3,10,10,10,10,10,10,10,10],
|
||||
|
||||
}
|
||||
fight_heros:any={ 0:5001, 1:5005, 2:0, 3:0, 4:0, }
|
||||
heros:any = {
|
||||
|
||||
@@ -15,6 +15,7 @@ export enum GameEvent {
|
||||
MAP_MOVE_END_LEFT = "MAP_MOVE_END_LEFT",
|
||||
MAP_MOVE_END_RIGHT = "MAP_MOVE_END_RIGHT",
|
||||
UpdateHero = "UpdateHero",
|
||||
UpdateFightHero = "UpdateFightHero",
|
||||
CastSkill = "CastSkill",
|
||||
CardsClose = "CardsClose",
|
||||
CardRefresh = "CardRefresh",
|
||||
|
||||
@@ -13,6 +13,15 @@ export enum CType{
|
||||
FREE=3, //免费
|
||||
AD=4, //广告
|
||||
}
|
||||
export const getRandomGoods=()=>{
|
||||
let goods=[1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023]
|
||||
// 随机打乱数组
|
||||
for (let i = goods.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[goods[i], goods[j]] = [goods[j], goods[i]];
|
||||
}
|
||||
return goods.slice(0, 8);
|
||||
}
|
||||
export const Goods={
|
||||
1001:{i_uuid:Items[9001].uuid,num:10000,cast:0,type:GType.GOLD,c_type:CType.FREE},
|
||||
1002:{i_uuid:Items[9002].uuid,num:100000,cast:0,type:GType.GOLD,c_type:CType.AD,},
|
||||
@@ -21,4 +30,20 @@ export const Goods={
|
||||
1005:{i_uuid:Items[9005].uuid,num:200,cast:0,type:GType.DIAMOND,c_type:CType.FREE},
|
||||
1006:{i_uuid:Items[9006].uuid,num:300,cast:0,type:GType.DIAMOND,c_type:CType.AD},
|
||||
1007:{i_uuid:Items[9007].uuid,num:500,cast:0,type:GType.DIAMOND,c_type:CType.AD},
|
||||
1008:{i_uuid:Items[1001].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1009:{i_uuid:Items[1002].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1010:{i_uuid:Items[1003].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1011:{i_uuid:Items[1004].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1012:{i_uuid:Items[1005].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1013:{i_uuid:Items[1006].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1014:{i_uuid:Items[1007].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1015:{i_uuid:Items[1008].uuid,num:1,cast:1,type:GType.ITEM,c_type:CType.DIAMOND},
|
||||
1016:{i_uuid:Items[1001].uuid,num:1,cast:10000,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1017:{i_uuid:Items[1002].uuid,num:1,cast:100000,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1018:{i_uuid:Items[1003].uuid,num:1,cast:500000,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1019:{i_uuid:Items[1004].uuid,num:1,cast:100,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1020:{i_uuid:Items[1005].uuid,num:1,cast:200,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1021:{i_uuid:Items[1006].uuid,num:1,cast:300,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1022:{i_uuid:Items[1007].uuid,num:1,cast:500,type:GType.ITEM,c_type:CType.GOLD},
|
||||
1023:{i_uuid:Items[1008].uuid,num:1,cast:1000,type:GType.ITEM,c_type:CType.GOLD},
|
||||
}
|
||||
@@ -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