feat(卡池): 新增基于波次的卡池自动升级功能
- 在 GameEvent 枚举中添加 CardPoolUpgrade 事件 - 在 MissionComp 中配置卡池升级波次并触发升级事件 - 在 MissionCardComp 中监听升级事件并更新卡池等级和UI - 升级时通过 toast 提示玩家
This commit is contained in:
@@ -264,6 +264,7 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.on(GameEvent.HeroDead, this.onHeroDead, this);
|
||||
oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this);
|
||||
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
|
||||
oops.message.on(GameEvent.CardPoolUpgrade, this.onCardPoolUpgrade, this);
|
||||
|
||||
/** 按钮触控事件:抽卡与卡池升级 */
|
||||
this.cards_chou?.on(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
|
||||
@@ -299,6 +300,33 @@ export class MissionCardComp extends CCComp {
|
||||
this.enterBattlePhase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收卡池升级事件:
|
||||
* - 更新卡池等级
|
||||
* - 更新UI显示
|
||||
*/
|
||||
private onCardPoolUpgrade(event: string, args: any) {
|
||||
const targetLv = args?.targetLv;
|
||||
if (!targetLv) return;
|
||||
|
||||
if (targetLv > CARD_POOL_MAX_LEVEL) {
|
||||
this.poolLv = CARD_POOL_MAX_LEVEL;
|
||||
} else {
|
||||
this.poolLv = targetLv;
|
||||
}
|
||||
|
||||
mLogger.log(this.debugMode, "MissionCardComp", "onCardPoolUpgrade", {
|
||||
targetLv,
|
||||
poolLv: this.poolLv
|
||||
});
|
||||
|
||||
// 提示卡池升级
|
||||
oops.gui.toast(`卡池已升至${this.poolLv}级`);
|
||||
|
||||
// 更新UI
|
||||
this.updatePoolLvUI();
|
||||
}
|
||||
|
||||
/** 新一波:展开面板 → 刷新费用 UI → 重新抽卡分发 */
|
||||
private onNewWave() {
|
||||
this.enterPreparePhase();
|
||||
@@ -315,6 +343,7 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.off(GameEvent.HeroDead, this.onHeroDead, this);
|
||||
oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this);
|
||||
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
|
||||
oops.message.off(GameEvent.CardPoolUpgrade, this.onCardPoolUpgrade, this);
|
||||
this.cards_chou?.off(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
|
||||
this.cards_chou?.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this);
|
||||
this.cards_chou?.off(NodeEventType.TOUCH_CANCEL, this.onDrawTouchCancel, this);
|
||||
|
||||
Reference in New Issue
Block a user