feat(卡池): 新增基于波次的卡池自动升级功能

- 在 GameEvent 枚举中添加 CardPoolUpgrade 事件
- 在 MissionComp 中配置卡池升级波次并触发升级事件
- 在 MissionCardComp 中监听升级事件并更新卡池等级和UI
- 升级时通过 toast 提示玩家
This commit is contained in:
walkpan
2026-04-12 22:56:01 +08:00
parent 09f64b0855
commit e1c8e92bd8
3 changed files with 50 additions and 1 deletions

View File

@@ -73,6 +73,7 @@ export enum GameEvent {
UpdateMissionGet = "UpdateMissionGet", UpdateMissionGet = "UpdateMissionGet",
GlobalAttrChange = "GlobalAttrChange", GlobalAttrChange = "GlobalAttrChange",
CoinAdd = "CoinAdd", CoinAdd = "CoinAdd",
CardPoolUpgrade = "CardPoolUpgrade",
TriggerSkill = "TriggerSkill", // 瞬间触发施法事件 TriggerSkill = "TriggerSkill", // 瞬间触发施法事件
RemoveSkillBox = "RemoveSkillBox", // 技能盒销毁事件 RemoveSkillBox = "RemoveSkillBox", // 技能盒销毁事件
} }

View File

@@ -264,6 +264,7 @@ export class MissionCardComp extends CCComp {
oops.message.on(GameEvent.HeroDead, this.onHeroDead, this); oops.message.on(GameEvent.HeroDead, this.onHeroDead, this);
oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this); oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this);
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, 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); this.cards_chou?.on(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
@@ -299,6 +300,33 @@ export class MissionCardComp extends CCComp {
this.enterBattlePhase(); 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 → 重新抽卡分发 */ /** 新一波:展开面板 → 刷新费用 UI → 重新抽卡分发 */
private onNewWave() { private onNewWave() {
this.enterPreparePhase(); this.enterPreparePhase();
@@ -315,6 +343,7 @@ export class MissionCardComp extends CCComp {
oops.message.off(GameEvent.HeroDead, this.onHeroDead, this); oops.message.off(GameEvent.HeroDead, this.onHeroDead, this);
oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this); oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this);
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, 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_START, this.onDrawTouchStart, this);
this.cards_chou?.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this); this.cards_chou?.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this);
this.cards_chou?.off(NodeEventType.TOUCH_CANCEL, this.onDrawTouchCancel, this); this.cards_chou?.off(NodeEventType.TOUCH_CANCEL, this.onDrawTouchCancel, this);

View File

@@ -27,7 +27,7 @@
* - CardInitCoins —— 初始金币数 * - CardInitCoins —— 初始金币数
* - UIID.Victory —— 结算弹窗 * - UIID.Victory —— 结算弹窗
*/ */
import { _decorator, Vec3,Animation, instantiate, Prefab, Node, NodeEventType, ProgressBar, Label } from "cc"; import { _decorator, Vec3,Animation, instantiate, Prefab, Node, NodeEventType, ProgressBar, Label, CCInteger } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
@@ -74,6 +74,9 @@ export class MissionComp extends CCComp {
private prepareCoinWaveGrow: number = 1; private prepareCoinWaveGrow: number = 1;
/** 金币奖励上限 */ /** 金币奖励上限 */
private prepareCoinRewardCap: number = 500; private prepareCoinRewardCap: number = 500;
/** 卡池升级波次配置:达到对应波次时,推送卡池升级事件 */
@property({ type: [CCInteger], tooltip: "卡池升级波次配置,例如 [10, 20] 表示第10波升到2级第20波升到3级" })
cardPoolUpgradeWaves: number[] = [5, 10];
// ======================== 编辑器绑定节点 ======================== // ======================== 编辑器绑定节点 ========================
@@ -382,6 +385,22 @@ export class MissionComp extends CCComp {
this.grantPrepareCoinByWave(wave); this.grantPrepareCoinByWave(wave);
this.lastTimeSecond = -1; this.lastTimeSecond = -1;
this.update_time(); this.update_time();
// 检查并推送卡池升级事件
this.checkCardPoolUpgrade(wave);
}
/** 检查是否达到卡池升级波次,并推送升级事件 */
private checkCardPoolUpgrade(wave: number) {
if (!this.cardPoolUpgradeWaves || this.cardPoolUpgradeWaves.length === 0) return;
const upgradeIndex = this.cardPoolUpgradeWaves.indexOf(wave);
if (upgradeIndex !== -1) {
// 根据配置的索引,计算目标等级(初始等级 + index + 1
// 例如 index=0对应等级为2index=1对应等级为3
const targetLv = upgradeIndex + 2;
oops.message.dispatchEvent(GameEvent.CardPoolUpgrade, { wave, targetLv });
mLogger.log(this.debugMode, 'MissionComp', "card pool upgrade event pushed", { wave, targetLv });
}
} }
/** /**