|
@@ -3,9 +3,9 @@ import { GameEvent } from '../Enum/GameEvent';
|
|
import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
|
|
import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
|
|
import { GlobalConfig } from 'db://assets/start/Config/GlobalConfig';
|
|
import { GlobalConfig } from 'db://assets/start/Config/GlobalConfig';
|
|
import { AdvertMgr } from 'db://assets/core_tgx/base/ad/AdvertMgr';
|
|
import { AdvertMgr } from 'db://assets/core_tgx/base/ad/AdvertMgr';
|
|
-import { TYPE_ITEM } from '../StormSunderGlobalInstance';
|
|
|
|
import { tgxUIAlert } from 'db://assets/core_tgx/tgx';
|
|
import { tgxUIAlert } from 'db://assets/core_tgx/tgx';
|
|
import { StormSunderAudioMgr } from '../Manager/StormSunderAudioMgr';
|
|
import { StormSunderAudioMgr } from '../Manager/StormSunderAudioMgr';
|
|
|
|
+import { AttributeBonusMgr, BonusType } from '../Manager/AttributeBonusMgr';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -13,23 +13,55 @@ const { ccclass, property } = _decorator;
|
|
*/
|
|
*/
|
|
@ccclass('ButtonComponent')
|
|
@ccclass('ButtonComponent')
|
|
export class ButtonComponent extends Component {
|
|
export class ButtonComponent extends Component {
|
|
- @property(Button) btnFillUp: Button = null!;
|
|
|
|
- @property(Button) btMoveOut: Button = null!;
|
|
|
|
- @property(Button) btRefresh: Button = null!;
|
|
|
|
|
|
+ @property(Button) btnAttack: Button = null!;
|
|
|
|
+ @property(Button) btSpeed: Button = null!;
|
|
|
|
+ @property(Button) btExp: Button = null!;
|
|
|
|
|
|
protected start(): void {
|
|
protected start(): void {
|
|
this.addUIEvent();
|
|
this.addUIEvent();
|
|
|
|
+ this.updateBtView(BonusType.ATTACK);
|
|
|
|
+ this.updateBtView(BonusType.SPEED);
|
|
|
|
+ this.updateBtView(BonusType.EXP);
|
|
}
|
|
}
|
|
|
|
|
|
private addUIEvent(): void {
|
|
private addUIEvent(): void {
|
|
- this.btnFillUp.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(TYPE_ITEM.UP_ATTACK), this);
|
|
|
|
- this.btMoveOut.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(TYPE_ITEM.UP_SPEED), this);
|
|
|
|
- this.btRefresh.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(TYPE_ITEM.UP_EXP), this);
|
|
|
|
|
|
+ this.btnAttack.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.ATTACK), this);
|
|
|
|
+ this.btSpeed.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.SPEED), this);
|
|
|
|
+ this.btExp.node.on(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.EXP), this);
|
|
}
|
|
}
|
|
|
|
|
|
- private onClickHandler(type: TYPE_ITEM): void {
|
|
|
|
|
|
+ private onClickHandler(type: BonusType): void {
|
|
console.log("onClickHandler", type);
|
|
console.log("onClickHandler", type);
|
|
StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(2), 1.0);
|
|
StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(2), 1.0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private updateBtView(type: BonusType, max?: boolean): void {
|
|
|
|
+ const { userModel } = AttributeBonusMgr.inst;
|
|
|
|
+ const { bonusData } = userModel;
|
|
|
|
+ const buttonNode = this.getButtonNodeByType(type);
|
|
|
|
+
|
|
|
|
+ const lbLevel: Label = buttonNode.getChildByName('LbLv').getComponent(Label)!;
|
|
|
|
+ const useddMoney = buttonNode.getChildByName('UsedMoney')!;
|
|
|
|
+ const usedAd = buttonNode.getChildByName('UsedAd')!;
|
|
|
|
+ const lbMoney: Label = useddMoney.getChildByName('LbAmount').getComponent(Label)!;
|
|
|
|
+
|
|
|
|
+ if (max) {
|
|
|
|
+ lbLevel.string = 'MAX';
|
|
|
|
+ useddMoney.active = false;
|
|
|
|
+ usedAd.active = false;
|
|
|
|
+ } else {
|
|
|
|
+ const bonus = bonusData[type];
|
|
|
|
+ lbLevel.string = `LV.${bonus.level}`;
|
|
|
|
+ lbMoney.string = `${bonus.upgradeCost}`;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private getButtonNodeByType(type: BonusType): Node {
|
|
|
|
+ return {
|
|
|
|
+ [BonusType.ATTACK]: this.btnAttack.node,
|
|
|
|
+ [BonusType.SPEED]: this.btSpeed.node,
|
|
|
|
+ [BonusType.EXP]: this.btExp.node,
|
|
|
|
+ }[type];
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|