Explorar o código

修复 重开按钮等级

woso_javan hai 1 mes
pai
achega
d84324cae8

+ 4 - 0
assets/module_storm_sunder/Prefabs/UI/Result/UI_BattleResult_Impl.ts

@@ -62,6 +62,7 @@ export class UI_BattleResult_Impl extends UI_BattleResult {
         const rewardDevelop = Number((userModel.game_reward_develop / 100).toFixed(2));
         const rewardRank = Number((userModel.game_reward_rank / 100).toFixed(2));
         //最终奖励=[基础奖励×(1+属性提升值×属性养成加成)]×[1-(本局排名-1)×排名减益]
+        console.log(`userModel.game_reward_develop:${userModel.game_reward_develop} totalLevel:${totalLevel} rewardDevelop:${rewardDevelop} this.rank:${this.rank} rewardRank:${rewardRank}`)
         this.reward = Math.floor(userModel.game_reward_develop * (1 + totalLevel * rewardDevelop) * (1 - (this.rank - 1) * rewardRank));
 
         this.rewardMultiple = userModel.game_pass_reward_multiple;
@@ -91,6 +92,9 @@ export class UI_BattleResult_Impl extends UI_BattleResult {
     }
 
     private changeGameStatus(status: GameStatus): void {
+        if (status === GameStatus.None) {
+            EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_MAIN_BTN_LEVEL);
+        }
         GameMgr.inst.setGameStatus(status);
         this.node.removeFromParent();
         this.node.destroy();

+ 20 - 1
assets/module_storm_sunder/Script/Component/ButtonComponent.ts

@@ -16,7 +16,8 @@ export class ButtonComponent extends Component {
     @property(Button) btSpeed: Button = null!;
     @property(Button) btExp: Button = null!;
 
-    protected onEnable(): void {
+    protected start(): void {
+        this.unregisterUIEvent();
         this.addUIEvent();
         this.updateBtView(BonusType.ATTACK);
         this.updateBtView(BonusType.SPEED);
@@ -24,10 +25,26 @@ export class ButtonComponent extends Component {
         this.onUpdateBtnsStatus();
     }
 
+    private unregisterUIEvent(): void {
+        this.btnAttack.node.off(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.ATTACK), this);
+        this.btSpeed.node.off(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.SPEED), this);
+        this.btExp.node.off(NodeEventType.TOUCH_END, () => this.onClickHandler(BonusType.EXP), this);
+        EventDispatcher.instance.off(GameEvent.EVENT_REFRESH_MAIN_BTN_LEVEL, this.onUpdateBtnsView, this);
+    }
+
     private addUIEvent(): void {
         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);
+
+        EventDispatcher.instance.on(GameEvent.EVENT_REFRESH_MAIN_BTN_LEVEL, this.onUpdateBtnsView, this);
+    }
+
+    private onUpdateBtnsView(): void {
+        this.updateBtView(BonusType.ATTACK);
+        this.updateBtView(BonusType.SPEED);
+        this.updateBtView(BonusType.EXP);
+        this.onUpdateBtnsStatus();
     }
 
     private onClickHandler(type: BonusType): void {
@@ -42,6 +59,7 @@ export class ButtonComponent extends Component {
                     this.upLevelBonus(type);
                 })
             } else {
+                console.log(`debugg 模式 增加等级!`);
                 this.upLevelBonus(type);
             }
         }
@@ -51,6 +69,7 @@ export class ButtonComponent extends Component {
             return;
         }
 
+        console.log(`提升等级:${type}`);
         this.upLevelBonus(type);
         // console.log(`当前属性最终加成:${AttributeBonusMgr.inst.getBonus(type)}`);
     }

+ 3 - 0
assets/module_storm_sunder/Script/Enum/GameEvent.ts

@@ -6,6 +6,9 @@ export class GameEvent {
     /**龙卷风重置*/
     static readonly EVENT_STORM_RESET = 'EVENT_STORM_RESET';
 
+    /**刷新主界面按钮等级*/
+    static readonly EVENT_REFRESH_MAIN_BTN_LEVEL = 'EVENT_REFRESH_MAIN_BTN_LEVEL';
+
     /** 龙卷风复活*/
     static readonly EVENT_STORM_RESURRECT = 'EVENT_STORM_RESURRECT';