You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
4.2 KiB
101 lines
4.2 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc";
|
|
import UIParse from "../../Mgr_UI/UIParse";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
import BuildDataPoxy from "../../const/BuildDataPoxy";
|
|
import { PropType } from "../../const/GameEnum";
|
|
import { EUIForms } from "../../const/UIFormCnf";
|
|
import { COLOR_PARAMS } from "../../const/GGameData";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("buildItem_Proxy")
|
|
export default class buildItem_Proxy extends UIParse{
|
|
//#region 节点自动生成
|
|
@property(Label)
|
|
lab_name: Label = null;
|
|
@property(Node)
|
|
n_Info: Node = null;
|
|
@property(Label)
|
|
lab_Lv: Label = null;
|
|
@property(Label)
|
|
lab_CoinSecond: Label = null;
|
|
@property(Label)
|
|
lab_addCoin: Label = null;
|
|
@property(Button)
|
|
btn_UpBuild: Button = null;
|
|
@property(Label)
|
|
lab_up: Label = null;
|
|
@property(Node)
|
|
n_red: Node = null;
|
|
@property(Node)
|
|
n_addeffect: Node = null;
|
|
@property(Label)
|
|
lab_effctcoin: Label = null;
|
|
@property(Node)
|
|
n_open: Node = null;
|
|
@property(Label)
|
|
lab_opencoin: Label = null;
|
|
@property(Button)
|
|
btn_OpenBuild: Button = null;
|
|
@property(Node)
|
|
n_openred: Node = null;
|
|
//#endregion 节点自动生成
|
|
private mBuildPoxy: BuildDataPoxy = null;
|
|
|
|
onButtonClick(button:Button){
|
|
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
case this.btn_UpBuild:
|
|
UIMgr.Ins.ShowUI(EUIForms.PopBuildLvUpUI,{param:{bData:this.mBuildPoxy,success:()=>{this.refreshBuild()}}});
|
|
break;
|
|
case this.btn_OpenBuild:
|
|
if(!this.mDataMgr.Token.checkToken(PropType.eGold, this.mBuildPoxy.upgradeCost)){
|
|
UIMgr.Ins.ShowTipsUI("铜钱不足!");
|
|
return false;
|
|
}
|
|
this.mBuildPoxy.running = true;
|
|
this.refreshBuild();
|
|
this.mDataMgr.Token.subToken(PropType.eGold, this.mBuildPoxy.upgradeCost);
|
|
break;
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 设置建筑数据
|
|
setBuildData(bid:number){
|
|
const isUnLock = this.mDataMgr.Build.hasBuilding(bid);
|
|
if(isUnLock){
|
|
this.mBuildPoxy = this.mDataMgr.Build.getBuildPoxy(bid);
|
|
this.refreshBuild();
|
|
}else{
|
|
CNodeUtils.setActive(this.n_Info, false);
|
|
CNodeUtils.setActive(this.n_open, false);
|
|
CNodeUtils.addNoScaleBtnComponent(this.node,this.ShowLockTips.bind(this),this)
|
|
}
|
|
}
|
|
ShowLockTips(){
|
|
UIMgr.Ins.ShowTipsUI("未解锁")
|
|
}
|
|
|
|
refreshBuild() {
|
|
const redpoint = this.mDataMgr.Build.canUpgrade(this.mBuildPoxy);
|
|
CNodeUtils.setActive(this.n_red, redpoint);
|
|
CNodeUtils.setActive(this.n_addeffect, this.mBuildPoxy.running);
|
|
CNodeUtils.setActive(this.n_Info, this.mBuildPoxy.running);
|
|
CNodeUtils.setActive(this.n_open, !this.mBuildPoxy.running);
|
|
CNodeUtils.switchText(this.lab_Lv,`lv.${this.mBuildPoxy.level}`)
|
|
CNodeUtils.switchText(this.lab_CoinSecond,`${this.mBuildPoxy.income}两/秒`)
|
|
CNodeUtils.switchText(this.lab_addCoin,`+${this.mBuildPoxy.add - this.mBuildPoxy.income}两/秒`)
|
|
CNodeUtils.switchText(this.lab_effctcoin,`+${this.mBuildPoxy.income}两`)
|
|
if(!this.mBuildPoxy.running){
|
|
const cost = this.mBuildPoxy.upgradeCost;
|
|
const success = this.mDataMgr.Token.checkToken(PropType.eGold, cost)
|
|
this.lab_opencoin.color = success? COLOR_PARAMS.WHITE : COLOR_PARAMS.RED;
|
|
CNodeUtils.switchText(this.lab_opencoin,`${cost}`);
|
|
CNodeUtils.setActive(this.n_openred, success);
|
|
}
|
|
}
|
|
}
|