feat(mission): 添加结算页再来一次功能

1. 新增GameEvent.RestartMission事件用于重开本关
2. 重构结算弹窗按钮逻辑,适配失败关卡重试需求
3. 新增restartCurrentMission方法实现关卡重置逻辑
4. 调整胜利prefab的缩放和控件绑定
This commit is contained in:
panFD
2026-09-10 23:48:13 +08:00
parent 6f76a67024
commit 4b0c0f00f9
4 changed files with 95 additions and 39 deletions

View File

@@ -214,6 +214,8 @@ export class MissionComp extends CCComp {
this.on(GameEvent.DO_AD_BACK, this.do_ad, this)
// 结算弹窗"下一节"按钮推进关卡
this.on(GameEvent.NextSection, this.onNextSection, this)
// 结算弹窗"再来一次"按钮重开本关
this.on(GameEvent.RestartMission, this.onRestartMission, this)
this.start_btn?.on(NodeEventType.TOUCH_END, this.onStartFightBtnClick, this)
// 开局免费三选一选完后自动进入战斗
oops.message.on("OpeningPicksDone", this.onOpeningPicksDone, this);
@@ -765,6 +767,12 @@ export class MissionComp extends CCComp {
this.advanceToNextSection();
}
/** 结算弹窗"再来一次"事件:关闭弹窗并重开本关 */
private onRestartMission() {
oops.gui.remove(UIID.Victory);
this.restartCurrentMission();
}
/** 开局免费三选一选完,自动进入战斗(等效于点击开始按钮) */
private onOpeningPicksDone() {
if (this.currentPhase !== MissionPhase.Prepare) return;
@@ -973,6 +981,34 @@ export class MissionComp extends CCComp {
`[StageProgress] 进入小节: ${getProgressText(this.currentChapter, this.currentStage, this.currentSection)}`);
}
/**
* 重开本关:清理战场并重置数据,从当前小节重新开始
* 与 advanceToNextSection 的区别:不推进小节进度,保持当前 section 不变
*/
private restartCurrentMission() {
// 清理战场与局内数据
this.cleanComponents();
this.clearBattlePools();
this.data_init();
// 重置结算状态
this._victory = false;
this._settleType = "defeat";
this._settleTitle = "";
// 进入准备阶段
this.changePhase(MissionPhase.Prepare);
// 触发 MissionStart 重置开局免费抽卡
oops.message.dispatchEvent(GameEvent.MissionStart, {});
oops.message.dispatchEvent(GameEvent.FightReady);
// 触发 SectionStart 重新生成当前小节怪物
oops.message.dispatchEvent(GameEvent.SectionStart, {
chapter: this.currentChapter,
stage: this.currentStage,
section: this.currentSection,
});
mLogger.log(this.debugMode, 'MissionComp',
`[StageProgress] 重开本关: ${getProgressText(this.currentChapter, this.currentStage, this.currentSection)}`);
}
// ======================== 回合管理 ========================
/**