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.
75 lines
3.6 KiB
75 lines
3.6 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc";
|
|
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
|
|
import Language from "../../Language";
|
|
import { PropType } from "../../const/GameEnum";
|
|
import { COLOR_PARAMS } from "../../const/GGameData";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
import MesMgr from "../../MesEvent/MesMgr";
|
|
import { EGlobalEvent } from "../../MesEvent/EGlobalEvent";
|
|
import StringUtils from "../../ExUtils/StringUtils";
|
|
import TreasureDataPoxy from "../../const/TreasureData";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("PopBuyTreaUI_Proxy")
|
|
export default class PopBuyTreaUI_Proxy extends BaseUIForm{
|
|
//#region 节点自动生成
|
|
@property(RichText)
|
|
ric_text: RichText = null;
|
|
@property(RichText)
|
|
ric_content: RichText = null;
|
|
@property(Button)
|
|
btn_No: Button = null;
|
|
@property(Button)
|
|
btn_Yes: Button = null;
|
|
@property(Label)
|
|
lab_coin: Label = null;
|
|
//#endregion 节点自动生成
|
|
private formatName:string = '';
|
|
onButtonClick(button:Button){
|
|
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
case this.btn_No:
|
|
this.CloseUI();
|
|
break;
|
|
case this.btn_Yes:
|
|
const coin = this.mDataMgr.Token.getTokenCount(PropType.eAdopt);
|
|
if(coin >= this.param.cfg.price || this.param.isfree){
|
|
if(this.param.isfree){
|
|
this.mDataMgr.Pass.free_times = 0;
|
|
}else{
|
|
this.mDataMgr.Token.subToken(PropType.eAdopt, this.param.cfg.price);
|
|
}
|
|
this.mDataMgr.Treasure.addTreasure(this.param.cfg.id);
|
|
UIMgr.Ins.ShowTipsUI(`恭喜获得${this.formatName}`);
|
|
MesMgr.event(EGlobalEvent.TREAS_BUY);
|
|
}else{
|
|
UIMgr.Ins.ShowTipsUI(`兑换失败,玄武符不足!`);
|
|
}
|
|
this.CloseUI();
|
|
break;
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected start(): void {
|
|
this.formatName = `<color=#F0A03B>${Language.getValue(this.param.cfg.name)}</color>`;
|
|
CNodeUtils.switchRichText(this.ric_text,`确认是否兑换${this.formatName}`);
|
|
const treas = this.mDataMgr.Treasure.getTreasureById(this.param.cfg.id);
|
|
const content: string = (treas!==null) ?`(当前等级:<color=#F0A03B>${treas.level}</color>)`:`(该珍宝<color=#F0A03B>未拥有</color>)`;
|
|
let prop1 = this.param.cfg.prop1;
|
|
let prop2 = this.param.cfg.prop2;
|
|
if(treas!==null){
|
|
prop1 = treas.prop1
|
|
prop2 = treas.prop2
|
|
}
|
|
let effect:string = this.param.cfg.prop2 === 0? StringUtils.format(this.param.cfg.display, prop1):StringUtils.format(this.param.cfg.display, prop1, prop2)
|
|
CNodeUtils.switchRichText(this.ric_content,`${content}\n效果:${effect}`);
|
|
const coin = this.mDataMgr.Token.getTokenCount(PropType.eAdopt);
|
|
this.lab_coin.color = (this.param.isfree || coin >= this.param.cfg.price)? COLOR_PARAMS.BLACK : COLOR_PARAMS.RED;
|
|
CNodeUtils.switchText(this.lab_coin,this.param.isfree?"免费":this.param.cfg.price);
|
|
}
|
|
}
|