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

@@ -27,7 +27,7 @@
* - CardInitCoins —— 初始金币数
* - 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 { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp";
@@ -74,6 +74,9 @@ export class MissionComp extends CCComp {
private prepareCoinWaveGrow: number = 1;
/** 金币奖励上限 */
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.lastTimeSecond = -1;
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 });
}
}
/**