refactor: 重构无限关模式,移除章节概念,统一使用关卡-回合结构
This commit is contained in:
@@ -5808,9 +5808,7 @@
|
|||||||
"watchPath": "",
|
"watchPath": "",
|
||||||
"labelType": "cc.Label",
|
"labelType": "cc.Label",
|
||||||
"watchPathArr": [
|
"watchPathArr": [
|
||||||
"data.stage_progress.chapter ",
|
"data.stage_progress.stage"
|
||||||
"data.stage_progress.stage",
|
|
||||||
"data.stage_progress.section"
|
|
||||||
],
|
],
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -48,11 +48,9 @@ export interface GameDate {
|
|||||||
talent_lv?: number,
|
talent_lv?: number,
|
||||||
/** 天赋当前等级已累计的经验值 */
|
/** 天赋当前等级已累计的经验值 */
|
||||||
talent_exp?: number,
|
talent_exp?: number,
|
||||||
/** 关卡进度存档:当前章节-关-节 */
|
/** 关卡进度存档:当前关卡号(无限关模式只记关卡号,回合恒从 1 开始) */
|
||||||
stage_progress?: {
|
stage_progress?: {
|
||||||
chapter: number,
|
|
||||||
stage: number,
|
stage: number,
|
||||||
section: number,
|
|
||||||
},
|
},
|
||||||
/** 奖励领取状态:段位/闯关首达奖励的已领取标记(玩家点击领取) */
|
/** 奖励领取状态:段位/闯关首达奖励的已领取标记(玩家点击领取) */
|
||||||
reward_claimed?: {
|
reward_claimed?: {
|
||||||
@@ -61,7 +59,7 @@ export interface GameDate {
|
|||||||
/** 已领取的大关号 */
|
/** 已领取的大关号 */
|
||||||
stage: number[],
|
stage: number[],
|
||||||
},
|
},
|
||||||
/** 已通关大关的显式标记(覆盖存档停留场景,如第 10 关通关后进度停留 1-10-10) */
|
/** 已通关大关的显式标记(历史遗留字段,无限关模式不再写入;仅用于兼容读取旧存档) */
|
||||||
passed_stages?: number[],
|
passed_stages?: number[],
|
||||||
}
|
}
|
||||||
export interface CloudData {
|
export interface CloudData {
|
||||||
@@ -152,11 +150,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
talent_lv: 0,
|
talent_lv: 0,
|
||||||
/** 当前等级已累计经验 */
|
/** 当前等级已累计经验 */
|
||||||
talent_exp: 0,
|
talent_exp: 0,
|
||||||
/** 关卡进度存档:默认从 1-1-1 开始 */
|
/** 关卡进度存档:默认从第 1 关开始 */
|
||||||
stage_progress: {
|
stage_progress: {
|
||||||
chapter: 1,
|
|
||||||
stage: 1,
|
stage: 1,
|
||||||
section: 1,
|
|
||||||
},
|
},
|
||||||
/** 奖励领取状态(玩家点击领取,跨局保留) */
|
/** 奖励领取状态(玩家点击领取,跨局保留) */
|
||||||
reward_claimed: {
|
reward_claimed: {
|
||||||
@@ -238,9 +234,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
switch_music: true, // 音乐开关(MVVM绑定字段)
|
switch_music: true, // 音乐开关(MVVM绑定字段)
|
||||||
/** 关卡进度(MVVM绑定字段,镜像 data.stage_progress,供 HUD 实时显示) */
|
/** 关卡进度(MVVM绑定字段,镜像 data.stage_progress,供 HUD 实时显示) */
|
||||||
stage_progress: {
|
stage_progress: {
|
||||||
chapter: 1,
|
|
||||||
stage: 1,
|
stage: 1,
|
||||||
section: 1,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -352,26 +346,26 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
* 将 data 层的关卡进度镜像到 vmdata 视图层(MVVM 绑定字段)。
|
* 将 data 层的关卡进度镜像到 vmdata 视图层(MVVM 绑定字段)。
|
||||||
* Why: data.stage_progress 为云端持久权威源,vmdata.stage_progress 仅供 HUD 绑定展示;
|
* Why: data.stage_progress 为云端持久权威源,vmdata.stage_progress 仅供 HUD 绑定展示;
|
||||||
* 登录覆盖、关卡推进后都必须调用本方法保持镜像一致。
|
* 登录覆盖、关卡推进后都必须调用本方法保持镜像一致。
|
||||||
|
* 旧版三段存档(chapter/stage/section)在同步时归一化为 stage 单字段。
|
||||||
*/
|
*/
|
||||||
public syncStageProgressToView(): void {
|
public syncStageProgressToView(): void {
|
||||||
const p = this.data.stage_progress;
|
const p = this.data.stage_progress;
|
||||||
// 就地更新字段而非整体替换对象:oops VM(JsonOb)只通知被赋值属性的精确路径,
|
// 旧存档归一化:兼容历史 chapter/stage/section 三段结构,仅提取 stage
|
||||||
// 整体替换仅派发 VC:data.stage_progress,不会触发 HUD 绑定的
|
const stage = Math.max(1, Math.floor(p?.stage ?? 1));
|
||||||
// data.stage_progress.section 等嵌套末端路径刷新,导致进度显示停留在老节
|
if (p && (p.stage !== stage || (p as any).chapter !== undefined || (p as any).section !== undefined)) {
|
||||||
const view = this.vmdata.stage_progress;
|
this.data.stage_progress = { stage };
|
||||||
view.chapter = p?.chapter ?? 1;
|
}
|
||||||
view.stage = p?.stage ?? 1;
|
this.vmdata.stage_progress.stage = stage;
|
||||||
view.section = p?.section ?? 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新关卡进度(权威源 data + 视图镜像 vmdata),并派发事件刷新 UI。
|
* 更新关卡进度(权威源 data + 视图镜像 vmdata),并派发事件刷新 UI。
|
||||||
* Why: 替代直接赋值 smc.data.stage_progress,保证视图层实时同步。
|
* Why: 替代直接赋值 smc.data.stage_progress,保证视图层实时同步。
|
||||||
* @param progress 新的关卡进度(章节/大关/小节均从 1 开始)
|
* @param progress 新的关卡进度(仅关卡号,从 1 开始)
|
||||||
* @param is_sync 是否标记脏并触发云端/本地同步
|
* @param is_sync 是否标记脏并触发云端/本地同步
|
||||||
*/
|
*/
|
||||||
public updateStageProgress(progress: { chapter: number; stage: number; section: number }, is_sync: boolean = true): void {
|
public updateStageProgress(progress: { stage: number }, is_sync: boolean = true): void {
|
||||||
this.data.stage_progress = { ...progress };
|
this.data.stage_progress = { stage: Math.max(1, Math.floor(progress.stage)) };
|
||||||
this.syncStageProgressToView();
|
this.syncStageProgressToView();
|
||||||
if (is_sync) {
|
if (is_sync) {
|
||||||
gameDataSync.markDataDirty();
|
gameDataSync.markDataDirty();
|
||||||
@@ -452,20 +446,18 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记大关已通关(通关点调用,覆盖存档停留场景)
|
* 标记大关已通关(历史遗留入口)
|
||||||
* Why: 第 10 关通关后存档停留 1-10-10,无法从 stage_progress 推导已通状态,
|
* Why: 旧版本第 10 关通关后存档停留,无法从 stage_progress 推导已通状态,需显式标记;
|
||||||
* 需在通关时显式写入。
|
* 无限关模式存档永远推进,判定已通可直接由 stage_progress 推导,无需再写入。
|
||||||
* @param stage 大关号
|
* 保留空实现以避免破坏外部调用方(若有旧存档读取场景走 passed_stages 兼容)。
|
||||||
|
* @param _stage 大关号(未使用,保留签名兼容)
|
||||||
|
* @deprecated 无限关模式无需调用,保留仅为兼容旧代码引用
|
||||||
*/
|
*/
|
||||||
public markStagePassed(stage: number): void {
|
public markStagePassed(_stage: number): void {
|
||||||
if (!this.data.passed_stages) this.data.passed_stages = [];
|
// 无限关模式不再写入 passed_stages
|
||||||
if (!this.data.passed_stages.includes(stage)) {
|
|
||||||
this.data.passed_stages.push(stage);
|
|
||||||
gameDataSync.markDataDirty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 判定大关是否已通关:显式标记优先,存档推进兜底(已进入后续关即已通关) */
|
/** 判定大关是否已通关:旧存档显式标记兼容,无限关以存档关卡号推导(已进入后续关即已通关) */
|
||||||
private isStagePassed(stage: number): boolean {
|
private isStagePassed(stage: number): boolean {
|
||||||
if ((this.data.passed_stages ?? []).includes(stage)) return true;
|
if ((this.data.passed_stages ?? []).includes(stage)) return true;
|
||||||
return (this.data.stage_progress?.stage ?? 1) > stage;
|
return (this.data.stage_progress?.stage ?? 1) > stage;
|
||||||
|
|||||||
@@ -104,15 +104,15 @@ export enum GameEvent {
|
|||||||
STAGE_PROGRESS_UPDATE = "STAGE_PROGRESS_UPDATE",
|
STAGE_PROGRESS_UPDATE = "STAGE_PROGRESS_UPDATE",
|
||||||
/** 奖励领取完成(payload 为空,UI 刷新待领取列表/红点) */
|
/** 奖励领取完成(payload 为空,UI 刷新待领取列表/红点) */
|
||||||
REWARD_CLAIMED = "REWARD_CLAIMED",
|
REWARD_CLAIMED = "REWARD_CLAIMED",
|
||||||
/** 小节开始(payload: { chapter, stage, section },MissionMonComp 据此生成怪物) */
|
/** 回合开始(payload: { stage, section },MissionMonComp 据此生成怪物) */
|
||||||
SectionStart = "SectionStart",
|
SectionStart = "SectionStart",
|
||||||
/** 小节结束(payload: { chapter, stage, section },玩家点击"下一节"后推进) */
|
/** @deprecated 已废弃:无限关模式无节间结算,回合自动推进,勿再监听 */
|
||||||
SectionEnd = "SectionEnd",
|
SectionEnd = "SectionEnd",
|
||||||
/** 大关结束(payload: { chapter, stage },10 节打完) */
|
/** @deprecated 已废弃:无限关模式无大关结算,勿再监听 */
|
||||||
StageEnd = "StageEnd",
|
StageEnd = "StageEnd",
|
||||||
/** 章节结束(payload: { chapter },10 关打完) */
|
/** @deprecated 已废弃:无限关模式无章节概念,勿再监听 */
|
||||||
ChapterEnd = "ChapterEnd",
|
ChapterEnd = "ChapterEnd",
|
||||||
/** 结算弹窗点击"下一节"(payload 为空,MissionComp 据此推进到下一小节) */
|
/** @deprecated 已废弃:无限关模式无"下一节"手动推进,勿再监听 */
|
||||||
NextSection = "NextSection",
|
NextSection = "NextSection",
|
||||||
/** 结算弹窗点击"再来一次"(payload 为空,MissionComp 据此重开本关) */
|
/** 结算弹窗点击"再来一次"(payload 为空,MissionComp 据此重开本关) */
|
||||||
RestartMission = "RestartMission",
|
RestartMission = "RestartMission",
|
||||||
|
|||||||
@@ -117,12 +117,11 @@ export function getSectionType(section: number): SectionType {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取回合配置(无限关:按需动态生成,不再依赖章节静态表)
|
* 获取回合配置(无限关:按需动态生成,不再依赖章节静态表)
|
||||||
* @param chapter 章节号(无限关模式已废弃章节概念,参数仅为兼容旧调用方,恒忽略)
|
|
||||||
* @param stage 关卡号(1~∞)
|
* @param stage 关卡号(1~∞)
|
||||||
* @param section 回合号(1~SECTIONS_PER_STAGE)
|
* @param section 回合号(1~SECTIONS_PER_STAGE)
|
||||||
* @returns 回合配置,回合号越界时返回 null
|
* @returns 回合配置,回合号越界时返回 null
|
||||||
*/
|
*/
|
||||||
export function getSectionConfig(chapter: number, stage: number, section: number): SectionConfig | null {
|
export function getSectionConfig(stage: number, section: number): SectionConfig | null {
|
||||||
if (section < 1 || section > SECTIONS_PER_STAGE) return null;
|
if (section < 1 || section > SECTIONS_PER_STAGE) return null;
|
||||||
|
|
||||||
const type = getSectionType(section);
|
const type = getSectionType(section);
|
||||||
@@ -140,12 +139,11 @@ export function getSectionConfig(chapter: number, stage: number, section: number
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前进度显示文本(无限关:只展示 关-回合,章节号恒忽略)
|
* 获取当前进度显示文本(无限关:只展示 关-回合)
|
||||||
* @param chapter 章节号(兼容参数,恒忽略)
|
|
||||||
* @param stage 关卡号
|
* @param stage 关卡号
|
||||||
* @param section 回合号
|
* @param section 回合号
|
||||||
* @returns 格式化文本,如 "5-3"
|
* @returns 格式化文本,如 "5-3"
|
||||||
*/
|
*/
|
||||||
export function getProgressText(chapter: number, stage: number, section: number): string {
|
export function getProgressText(stage: number, section: number): string {
|
||||||
return `${stage}-${section}`;
|
return `${stage}-${section}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,11 +180,9 @@ export class MissionComp extends CCComp {
|
|||||||
|
|
||||||
// ======================== 关卡进度状态 ========================
|
// ======================== 关卡进度状态 ========================
|
||||||
|
|
||||||
/** 当前章节号 */
|
/** 当前关卡号(无限关,1~∞) */
|
||||||
public currentChapter: number = 1;
|
|
||||||
/** 当前关卡号(1~10) */
|
|
||||||
public currentStage: number = 1;
|
public currentStage: number = 1;
|
||||||
/** 当前小节号(1~SECTIONS_PER_STAGE) */
|
/** 当前回合号(1~SECTIONS_PER_STAGE) */
|
||||||
public currentSection: number = 1;
|
public currentSection: number = 1;
|
||||||
|
|
||||||
// ======================== ECS 查询匹配器(预缓存) ========================
|
// ======================== ECS 查询匹配器(预缓存) ========================
|
||||||
@@ -370,7 +368,6 @@ export class MissionComp extends CCComp {
|
|||||||
this.changePhase(MissionPhase.Prepare);
|
this.changePhase(MissionPhase.Prepare);
|
||||||
// 派发首个 SectionStart,MissionMonComp 据此生成开局怪物
|
// 派发首个 SectionStart,MissionMonComp 据此生成开局怪物
|
||||||
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
||||||
chapter: this.currentChapter,
|
|
||||||
stage: this.currentStage,
|
stage: this.currentStage,
|
||||||
section: this.currentSection,
|
section: this.currentSection,
|
||||||
});
|
});
|
||||||
@@ -770,9 +767,7 @@ export class MissionComp extends CCComp {
|
|||||||
this._settleType = "final";
|
this._settleType = "final";
|
||||||
this._settleTitle = "本关通关";
|
this._settleTitle = "本关通关";
|
||||||
smc.updateStageProgress({
|
smc.updateStageProgress({
|
||||||
chapter: this.currentChapter,
|
|
||||||
stage: this.currentStage + 1,
|
stage: this.currentStage + 1,
|
||||||
section: 1,
|
|
||||||
});
|
});
|
||||||
if ((smc as any).updateCloudData) {
|
if ((smc as any).updateCloudData) {
|
||||||
(smc as any).updateCloudData();
|
(smc as any).updateCloudData();
|
||||||
@@ -865,57 +860,48 @@ export class MissionComp extends CCComp {
|
|||||||
// ======================== 关卡进度管理 ========================
|
// ======================== 关卡进度管理 ========================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载关卡进度存档(一关一局:只恢复大关,节恒从 1 开始)
|
* 加载关卡进度存档(一关一局:只恢复大关,回合恒从 1 开始)
|
||||||
* 从 smc.data.stage_progress 恢复章节/大关,缺省从 1-1-1 开始
|
* 从 smc.data.stage_progress 恢复关卡号,缺省从第 1 关开始
|
||||||
*/
|
*/
|
||||||
private loadStageProgress() {
|
private loadStageProgress() {
|
||||||
const progress = smc.data.stage_progress;
|
const progress = smc.data.stage_progress;
|
||||||
if (progress && progress.chapter >= 1 && progress.stage >= 1) {
|
this.currentStage = Math.max(1, Math.floor(progress?.stage ?? 1));
|
||||||
this.currentChapter = progress.chapter;
|
// 一关一局:进入关卡始终从第 1 回合开打
|
||||||
this.currentStage = progress.stage;
|
|
||||||
} else {
|
|
||||||
this.currentChapter = 1;
|
|
||||||
this.currentStage = 1;
|
|
||||||
}
|
|
||||||
// 一关一局:进入关卡始终从第 1 节开打
|
|
||||||
this.currentSection = 1;
|
this.currentSection = 1;
|
||||||
// 加载完成后将权威进度镜像到 vmdata,驱动 HUD 实时显示
|
// 加载完成后将权威进度镜像到 vmdata,驱动 HUD 实时显示
|
||||||
smc.syncStageProgressToView();
|
smc.syncStageProgressToView();
|
||||||
mLogger.log(this.debugMode, 'MissionComp',
|
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. 不清理英雄/技能实体、不重置局内数据、不重新三选一——英雄保留并自动归位(编队排队)。
|
* 2. 不清理英雄/技能实体、不重置局内数据、不重新三选一——英雄保留并自动归位(编队排队)。
|
||||||
* 3. 进度实时镜像到 HUD,但不写持久存档(存档只在整关通关时推进到下一关)。
|
* 3. 进度实时镜像到 HUD,但不写持久存档(存档只在整关通关时推进到下一关)。
|
||||||
*
|
*
|
||||||
* 调用时机:PrepareStart 过场倒计时结束(autoNextPhase)。
|
* 调用时机:PrepareStart 过场倒计时结束(autoNextPhase)。
|
||||||
* 保证:仅 1~4 节清场后触发,末节(BOSS_SECTION)已走 open_Victory 结算,不会推进。
|
* 保证:仅 1~4 回合清场后触发,末回合(BOSS_SECTION)已走 open_Victory 结算,不会推进。
|
||||||
*/
|
*/
|
||||||
private advanceToNextSection() {
|
private advanceToNextSection() {
|
||||||
this.currentSection++;
|
this.currentSection++;
|
||||||
// 节号实时同步到 HUD(内存进度,不持久化;整关通关时才统一写大关存档)。
|
// 回合号实时同步到 HUD(内存进度,不持久化;整关通关时才统一写大关存档)。
|
||||||
// 直接写 vmdata 视图层而非走 syncStageProgressToView(后者从 data 读,而 data 仍停留在大关起点)
|
// 直接写 vmdata 视图层而非走 syncStageProgressToView(后者从 data 读,而 data 仍停留在大关起点)
|
||||||
const view = smc.vmdata.stage_progress;
|
const view = smc.vmdata.stage_progress;
|
||||||
view.chapter = this.currentChapter;
|
|
||||||
view.stage = this.currentStage;
|
view.stage = this.currentStage;
|
||||||
view.section = this.currentSection;
|
|
||||||
oops.message.dispatchEvent(GameEvent.STAGE_PROGRESS_UPDATE);
|
oops.message.dispatchEvent(GameEvent.STAGE_PROGRESS_UPDATE);
|
||||||
// 触发 SectionStart 事件,MissionMonComp 据此生成下一节怪物(从右侧跑入)
|
// 触发 SectionStart 事件,MissionMonComp 据此生成下一回合怪物(从右侧跑入)
|
||||||
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
||||||
chapter: this.currentChapter,
|
|
||||||
stage: this.currentStage,
|
stage: this.currentStage,
|
||||||
section: this.currentSection,
|
section: this.currentSection,
|
||||||
});
|
});
|
||||||
mLogger.log(this.debugMode, 'MissionComp',
|
mLogger.log(this.debugMode, 'MissionComp',
|
||||||
`[StageProgress] 进入小节: ${getProgressText(this.currentChapter, this.currentStage, this.currentSection)}`);
|
`[StageProgress] 进入回合: ${getProgressText(this.currentStage, this.currentSection)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重开本关:清理战场并重置数据,从本关第 1 节重新开始
|
* 重开本关:清理战场并重置数据,从本关第 1 回合重新开始
|
||||||
* Why: 一关一局,失败"再来一次"即整关重打(节恒从 1 开始)
|
* Why: 一关一局,失败"再来一次"即整关重打(回合恒从 1 开始)
|
||||||
*/
|
*/
|
||||||
private restartCurrentMission() {
|
private restartCurrentMission() {
|
||||||
// 清理战场与局内数据
|
// 清理战场与局内数据
|
||||||
@@ -926,21 +912,20 @@ export class MissionComp extends CCComp {
|
|||||||
this._victory = false;
|
this._victory = false;
|
||||||
this._settleType = "defeat";
|
this._settleType = "defeat";
|
||||||
this._settleTitle = "";
|
this._settleTitle = "";
|
||||||
// 一关一局:重开从第 1 节开始
|
// 一关一局:重开从第 1 回合开始
|
||||||
this.currentSection = 1;
|
this.currentSection = 1;
|
||||||
// 进入准备阶段
|
// 进入准备阶段
|
||||||
this.changePhase(MissionPhase.Prepare);
|
this.changePhase(MissionPhase.Prepare);
|
||||||
// 触发 MissionStart 重置开局免费抽卡
|
// 触发 MissionStart 重置开局免费抽卡
|
||||||
oops.message.dispatchEvent(GameEvent.MissionStart, {});
|
oops.message.dispatchEvent(GameEvent.MissionStart, {});
|
||||||
oops.message.dispatchEvent(GameEvent.FightReady);
|
oops.message.dispatchEvent(GameEvent.FightReady);
|
||||||
// 触发 SectionStart 重新生成本关第 1 节怪物
|
// 触发 SectionStart 重新生成本关第 1 回合怪物
|
||||||
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
oops.message.dispatchEvent(GameEvent.SectionStart, {
|
||||||
chapter: this.currentChapter,
|
|
||||||
stage: this.currentStage,
|
stage: this.currentStage,
|
||||||
section: this.currentSection,
|
section: this.currentSection,
|
||||||
});
|
});
|
||||||
mLogger.log(this.debugMode, 'MissionComp',
|
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() { }
|
start() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小节开始事件回调:生成怪物列表并按节奏刷出
|
* 回合开始事件回调:生成怪物列表并按节奏刷出
|
||||||
* @param event 事件名
|
* @param event 事件名
|
||||||
* @param data { chapter, stage, section }
|
* @param data { stage, section }
|
||||||
*/
|
*/
|
||||||
private onSectionStart(event: string, data: any) {
|
private onSectionStart(event: string, data: any) {
|
||||||
const chapter = Number(data?.chapter ?? 1);
|
|
||||||
const stage = Number(data?.stage ?? 1);
|
const stage = Number(data?.stage ?? 1);
|
||||||
const section = Number(data?.section ?? 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.mon_num = 0;
|
||||||
smc.vmdata.mission_data.pending_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;
|
this.sectionTargetCount = monsters.length;
|
||||||
|
|
||||||
if (TestModeConfig.enable) {
|
if (TestModeConfig.enable) {
|
||||||
mLogger.log(this.debugMode, 'MissionMonComp', "[MissionMonComp] 测试模式已开启");
|
mLogger.log(this.debugMode, 'MissionMonComp', "[MissionMonComp] 测试模式已开启");
|
||||||
}
|
}
|
||||||
mLogger.log(this.debugMode, 'MissionMonComp',
|
mLogger.log(this.debugMode, 'MissionMonComp',
|
||||||
`[MissionMonComp] 小节 ${chapter}-${stage}-${section} 生成完成,怪物总数: ${this.sectionTargetCount}`);
|
`[MissionMonComp] 回合 ${stage}-${section} 生成完成,怪物总数: ${this.sectionTargetCount}`);
|
||||||
|
|
||||||
// 按批次拆分:batch=0 立即刷,batch=1 进入待刷队列
|
// 按批次拆分:batch=0 立即刷,batch=1 进入待刷队列
|
||||||
const immediate: GeneratedMonster[] = [];
|
const immediate: GeneratedMonster[] = [];
|
||||||
|
|||||||
@@ -255,18 +255,17 @@ export class StageSpawningEngine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成指定回合的怪物列表
|
* 生成指定回合的怪物列表
|
||||||
* @param chapter 章节号(无限关模式已废弃章节概念,兼容参数恒忽略)
|
|
||||||
* @param stage 关卡号(1~∞)
|
* @param stage 关卡号(1~∞)
|
||||||
* @param section 回合号(1~SECTIONS_PER_STAGE)
|
* @param section 回合号(1~SECTIONS_PER_STAGE)
|
||||||
* @returns 怪物列表(按刷出顺序排列)
|
* @returns 怪物列表(按刷出顺序排列)
|
||||||
*/
|
*/
|
||||||
generateSectionMonsters(chapter: number, stage: number, section: number): GeneratedMonster[] {
|
generateSectionMonsters(stage: number, section: number): GeneratedMonster[] {
|
||||||
// 测试模式拦截:完全绕过生成引擎,直接返回硬编码测试怪
|
// 测试模式拦截:完全绕过生成引擎,直接返回硬编码测试怪
|
||||||
if (TestModeConfig.enable) {
|
if (TestModeConfig.enable) {
|
||||||
return this.generateTestWave();
|
return this.generateTestWave();
|
||||||
}
|
}
|
||||||
|
|
||||||
const cfg = getSectionConfig(chapter, stage, section);
|
const cfg = getSectionConfig(stage, section);
|
||||||
if (!cfg) {
|
if (!cfg) {
|
||||||
// 配置缺失兜底:生成 3 只 Lv1 近战小怪
|
// 配置缺失兜底:生成 3 只 Lv1 近战小怪
|
||||||
return this.makeFallbackMonsters();
|
return this.makeFallbackMonsters();
|
||||||
|
|||||||
Reference in New Issue
Block a user