refactor: 重构无限关模式,移除章节概念,统一使用关卡-回合结构
This commit is contained in:
@@ -180,11 +180,9 @@ export class MissionComp extends CCComp {
|
||||
|
||||
// ======================== 关卡进度状态 ========================
|
||||
|
||||
/** 当前章节号 */
|
||||
public currentChapter: number = 1;
|
||||
/** 当前关卡号(1~10) */
|
||||
/** 当前关卡号(无限关,1~∞) */
|
||||
public currentStage: number = 1;
|
||||
/** 当前小节号(1~SECTIONS_PER_STAGE) */
|
||||
/** 当前回合号(1~SECTIONS_PER_STAGE) */
|
||||
public currentSection: number = 1;
|
||||
|
||||
// ======================== ECS 查询匹配器(预缓存) ========================
|
||||
@@ -370,7 +368,6 @@ export class MissionComp extends CCComp {
|
||||
this.changePhase(MissionPhase.Prepare);
|
||||
// 派发首个 SectionStart,MissionMonComp 据此生成开局怪物
|
||||
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
||||
chapter: this.currentChapter,
|
||||
stage: this.currentStage,
|
||||
section: this.currentSection,
|
||||
});
|
||||
@@ -770,9 +767,7 @@ export class MissionComp extends CCComp {
|
||||
this._settleType = "final";
|
||||
this._settleTitle = "本关通关";
|
||||
smc.updateStageProgress({
|
||||
chapter: this.currentChapter,
|
||||
stage: this.currentStage + 1,
|
||||
section: 1,
|
||||
});
|
||||
if ((smc as any).updateCloudData) {
|
||||
(smc as any).updateCloudData();
|
||||
@@ -865,57 +860,48 @@ export class MissionComp extends CCComp {
|
||||
// ======================== 关卡进度管理 ========================
|
||||
|
||||
/**
|
||||
* 加载关卡进度存档(一关一局:只恢复大关,节恒从 1 开始)
|
||||
* 从 smc.data.stage_progress 恢复章节/大关,缺省从 1-1-1 开始
|
||||
* 加载关卡进度存档(一关一局:只恢复大关,回合恒从 1 开始)
|
||||
* 从 smc.data.stage_progress 恢复关卡号,缺省从第 1 关开始
|
||||
*/
|
||||
private loadStageProgress() {
|
||||
const progress = smc.data.stage_progress;
|
||||
if (progress && progress.chapter >= 1 && progress.stage >= 1) {
|
||||
this.currentChapter = progress.chapter;
|
||||
this.currentStage = progress.stage;
|
||||
} else {
|
||||
this.currentChapter = 1;
|
||||
this.currentStage = 1;
|
||||
}
|
||||
// 一关一局:进入关卡始终从第 1 节开打
|
||||
this.currentStage = Math.max(1, Math.floor(progress?.stage ?? 1));
|
||||
// 一关一局:进入关卡始终从第 1 回合开打
|
||||
this.currentSection = 1;
|
||||
// 加载完成后将权威进度镜像到 vmdata,驱动 HUD 实时显示
|
||||
smc.syncStageProgressToView();
|
||||
mLogger.log(this.debugMode, 'MissionComp',
|
||||
`[StageProgress] 加载进度: ${getProgressText(this.currentChapter, this.currentStage, this.currentSection)}`);
|
||||
`[StageProgress] 加载进度: ${getProgressText(this.currentStage, this.currentSection)}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推进到下一小节(节间自动推进):
|
||||
* 1. 节号 +1,派发 SectionStart 触发 MissionMonComp 生成下一节怪物(从右侧跑入)。
|
||||
* 推进到下一回合(回合间自动推进):
|
||||
* 1. 回合号 +1,派发 SectionStart 触发 MissionMonComp 生成下一回合怪物(从右侧跑入)。
|
||||
* 2. 不清理英雄/技能实体、不重置局内数据、不重新三选一——英雄保留并自动归位(编队排队)。
|
||||
* 3. 进度实时镜像到 HUD,但不写持久存档(存档只在整关通关时推进到下一关)。
|
||||
*
|
||||
* 调用时机:PrepareStart 过场倒计时结束(autoNextPhase)。
|
||||
* 保证:仅 1~4 节清场后触发,末节(BOSS_SECTION)已走 open_Victory 结算,不会推进。
|
||||
* 保证:仅 1~4 回合清场后触发,末回合(BOSS_SECTION)已走 open_Victory 结算,不会推进。
|
||||
*/
|
||||
private advanceToNextSection() {
|
||||
this.currentSection++;
|
||||
// 节号实时同步到 HUD(内存进度,不持久化;整关通关时才统一写大关存档)。
|
||||
// 回合号实时同步到 HUD(内存进度,不持久化;整关通关时才统一写大关存档)。
|
||||
// 直接写 vmdata 视图层而非走 syncStageProgressToView(后者从 data 读,而 data 仍停留在大关起点)
|
||||
const view = smc.vmdata.stage_progress;
|
||||
view.chapter = this.currentChapter;
|
||||
view.stage = this.currentStage;
|
||||
view.section = this.currentSection;
|
||||
oops.message.dispatchEvent(GameEvent.STAGE_PROGRESS_UPDATE);
|
||||
// 触发 SectionStart 事件,MissionMonComp 据此生成下一节怪物(从右侧跑入)
|
||||
// 触发 SectionStart 事件,MissionMonComp 据此生成下一回合怪物(从右侧跑入)
|
||||
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)}`);
|
||||
`[StageProgress] 进入回合: ${getProgressText(this.currentStage, this.currentSection)}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重开本关:清理战场并重置数据,从本关第 1 节重新开始
|
||||
* Why: 一关一局,失败"再来一次"即整关重打(节恒从 1 开始)
|
||||
* 重开本关:清理战场并重置数据,从本关第 1 回合重新开始
|
||||
* Why: 一关一局,失败"再来一次"即整关重打(回合恒从 1 开始)
|
||||
*/
|
||||
private restartCurrentMission() {
|
||||
// 清理战场与局内数据
|
||||
@@ -926,21 +912,20 @@ export class MissionComp extends CCComp {
|
||||
this._victory = false;
|
||||
this._settleType = "defeat";
|
||||
this._settleTitle = "";
|
||||
// 一关一局:重开从第 1 节开始
|
||||
// 一关一局:重开从第 1 回合开始
|
||||
this.currentSection = 1;
|
||||
// 进入准备阶段
|
||||
this.changePhase(MissionPhase.Prepare);
|
||||
// 触发 MissionStart 重置开局免费抽卡
|
||||
oops.message.dispatchEvent(GameEvent.MissionStart, {});
|
||||
oops.message.dispatchEvent(GameEvent.FightReady);
|
||||
// 触发 SectionStart 重新生成本关第 1 节怪物
|
||||
// 触发 SectionStart 重新生成本关第 1 回合怪物
|
||||
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)}`);
|
||||
`[StageProgress] 重开本关: ${getProgressText(this.currentStage, this.currentSection)}`);
|
||||
}
|
||||
|
||||
// ======================== 回合管理 ========================
|
||||
|
||||
@@ -124,12 +124,11 @@ export class MissionMonCompComp extends CCComp {
|
||||
start() { }
|
||||
|
||||
/**
|
||||
* 小节开始事件回调:生成怪物列表并按节奏刷出
|
||||
* 回合开始事件回调:生成怪物列表并按节奏刷出
|
||||
* @param event 事件名
|
||||
* @param data { chapter, stage, section }
|
||||
* @param data { stage, section }
|
||||
*/
|
||||
private onSectionStart(event: string, data: any) {
|
||||
const chapter = Number(data?.chapter ?? 1);
|
||||
const stage = Number(data?.stage ?? 1);
|
||||
const section = Number(data?.section ?? 1);
|
||||
|
||||
@@ -142,15 +141,15 @@ export class MissionMonCompComp extends CCComp {
|
||||
smc.vmdata.mission_data.mon_num = 0;
|
||||
smc.vmdata.mission_data.pending_mon_num = 0;
|
||||
|
||||
// 从生成引擎获取本小节怪物列表
|
||||
const monsters = spawningEngine.generateSectionMonsters(chapter, stage, section);
|
||||
// 从生成引擎获取本回合怪物列表
|
||||
const monsters = spawningEngine.generateSectionMonsters(stage, section);
|
||||
this.sectionTargetCount = monsters.length;
|
||||
|
||||
if (TestModeConfig.enable) {
|
||||
mLogger.log(this.debugMode, 'MissionMonComp', "[MissionMonComp] 测试模式已开启");
|
||||
}
|
||||
mLogger.log(this.debugMode, 'MissionMonComp',
|
||||
`[MissionMonComp] 小节 ${chapter}-${stage}-${section} 生成完成,怪物总数: ${this.sectionTargetCount}`);
|
||||
`[MissionMonComp] 回合 ${stage}-${section} 生成完成,怪物总数: ${this.sectionTargetCount}`);
|
||||
|
||||
// 按批次拆分:batch=0 立即刷,batch=1 进入待刷队列
|
||||
const immediate: GeneratedMonster[] = [];
|
||||
|
||||
@@ -255,18 +255,17 @@ export class StageSpawningEngine {
|
||||
|
||||
/**
|
||||
* 生成指定回合的怪物列表
|
||||
* @param chapter 章节号(无限关模式已废弃章节概念,兼容参数恒忽略)
|
||||
* @param stage 关卡号(1~∞)
|
||||
* @param section 回合号(1~SECTIONS_PER_STAGE)
|
||||
* @returns 怪物列表(按刷出顺序排列)
|
||||
*/
|
||||
generateSectionMonsters(chapter: number, stage: number, section: number): GeneratedMonster[] {
|
||||
generateSectionMonsters(stage: number, section: number): GeneratedMonster[] {
|
||||
// 测试模式拦截:完全绕过生成引擎,直接返回硬编码测试怪
|
||||
if (TestModeConfig.enable) {
|
||||
return this.generateTestWave();
|
||||
}
|
||||
|
||||
const cfg = getSectionConfig(chapter, stage, section);
|
||||
const cfg = getSectionConfig(stage, section);
|
||||
if (!cfg) {
|
||||
// 配置缺失兜底:生成 3 只 Lv1 近战小怪
|
||||
return this.makeFallbackMonsters();
|
||||
|
||||
Reference in New Issue
Block a user