feat(卡池): 新增基于波次的卡池自动升级功能
- 在 GameEvent 枚举中添加 CardPoolUpgrade 事件 - 在 MissionComp 中配置卡池升级波次并触发升级事件 - 在 MissionCardComp 中监听升级事件并更新卡池等级和UI - 升级时通过 toast 提示玩家
This commit is contained in:
@@ -73,6 +73,7 @@ export enum GameEvent {
|
||||
UpdateMissionGet = "UpdateMissionGet",
|
||||
GlobalAttrChange = "GlobalAttrChange",
|
||||
CoinAdd = "CoinAdd",
|
||||
CardPoolUpgrade = "CardPoolUpgrade",
|
||||
TriggerSkill = "TriggerSkill", // 瞬间触发施法事件
|
||||
RemoveSkillBox = "RemoveSkillBox", // 技能盒销毁事件
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,对应等级为2;index=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 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user