refactor(map): 重构关卡刷怪与计时逻辑,适配30波新流程
1. 替换原固定战斗倒计时为正向计时clearTime 2. 移除旧波次配置,改用spawningEngine生成自适应怪物 3. 将波次上限从20调整为30,更新对应判断逻辑 4. 实现增量分批刷怪和自适应难度调整 5. 重置战斗状态时重置新引擎实例
This commit is contained in:
@@ -46,6 +46,7 @@ import { Tooltip } from "../skill/Tooltip";
|
||||
import { CardInitCoins } from "../common/config/CardSet";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { spawningEngine } from "./RogueConfig";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 任务(关卡)生命周期阶段 */
|
||||
@@ -118,8 +119,8 @@ export class MissionComp extends CCComp {
|
||||
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
/** 战斗倒计时(秒) */
|
||||
FightTime:number = FightSet.FiIGHT_TIME
|
||||
/** 战斗已耗时(秒),正向计时 */
|
||||
clearTime:number = 0
|
||||
/** 剩余复活次数 */
|
||||
revive_times: number = 1;
|
||||
/** 掉落奖励列表 */
|
||||
@@ -234,14 +235,7 @@ export class MissionComp extends CCComp {
|
||||
this.syncMonsterSpawnState(dt)
|
||||
if(smc.mission.stop_mon_action) return
|
||||
smc.vmdata.mission_data.fight_time+=dt
|
||||
if (!this.isBossWave) {
|
||||
this.FightTime-=dt
|
||||
if (this.FightTime <= 0) {
|
||||
// 时间到了,自动结束战斗进入准备阶段
|
||||
this.FightTime = FightSet.FiIGHT_TIME;
|
||||
oops.message.dispatchEvent("TimeUpAdvanceWave");
|
||||
}
|
||||
}
|
||||
this.clearTime += dt
|
||||
this.update_time();
|
||||
}
|
||||
}
|
||||
@@ -250,29 +244,11 @@ export class MissionComp extends CCComp {
|
||||
|
||||
/** 更新时间/波数显示(仅在秒数变化时更新以减少 Label 操作) */
|
||||
update_time(){
|
||||
if (this.isBossWave) {
|
||||
const str = "∞";
|
||||
if (str != this.lastTimeStr) {
|
||||
if (this.time_node && this.time_node.isValid) {
|
||||
const timeChild = this.time_node.getChildByName("time");
|
||||
if (timeChild) {
|
||||
const label = timeChild.getComponent(Label);
|
||||
if (label) label.string = str;
|
||||
}
|
||||
}
|
||||
this.lastTimeStr = str;
|
||||
this.lastTimeSecond = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const time = Math.max(0, this.FightTime);
|
||||
const remainSecond = Math.floor(time);
|
||||
const remainSecond = Math.floor(this.clearTime);
|
||||
if (remainSecond === this.lastTimeSecond) return;
|
||||
this.lastTimeSecond = remainSecond;
|
||||
let m = Math.floor(remainSecond / 60);
|
||||
let s = remainSecond % 60;
|
||||
const wave = Math.max(1, this.currentWave || smc.vmdata.mission_data.level || 1);
|
||||
let str = `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
|
||||
if(str != this.lastTimeStr){
|
||||
if (this.time_node && this.time_node.isValid) {
|
||||
@@ -422,7 +398,7 @@ export class MissionComp extends CCComp {
|
||||
const label = phaseNode.getComponent(Label);
|
||||
if (label) {
|
||||
const wave = Math.max(1, this.currentWave || (smc.vmdata && smc.vmdata.mission_data ? smc.vmdata.mission_data.level : 1) || 1);
|
||||
label.string = `第 ${wave}/20 波`;
|
||||
label.string = `第 ${wave}/30 波`;
|
||||
}
|
||||
|
||||
// 阶段切换动感表现:只在进入战斗阶段跳动一下,让流程充满心流体验
|
||||
@@ -497,8 +473,8 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.scores.wave_all_alive_count++;
|
||||
}
|
||||
|
||||
// 【评分系统 - 战绩分】判断是否通过最后一关(第20回合)
|
||||
if (this.currentWave === 20) {
|
||||
// 【评分系统 - 战绩分】判断是否通过最后一关(第30回合)
|
||||
if (this.currentWave === 30) {
|
||||
smc.vmdata.scores.passed_wave_20 = true;
|
||||
}
|
||||
}
|
||||
@@ -721,13 +697,13 @@ export class MissionComp extends CCComp {
|
||||
smc.mission.stop_spawn_mon = false;
|
||||
smc.vmdata.mission_data.in_fight=false
|
||||
smc.vmdata.mission_data.fight_time=0
|
||||
this.clearTime = 0
|
||||
smc.vmdata.mission_data.mon_num=0
|
||||
smc.vmdata.mission_data.level = 1
|
||||
smc.vmdata.mission_data.mon_max = Math.max(1, Math.floor(this.maxMonsterCount))
|
||||
this.currentPhase = MissionPhase.None;
|
||||
this.currentWave = 1;
|
||||
this.isBossWave = false;
|
||||
this.FightTime=FightSet.FiIGHT_TIME
|
||||
this.rewards=[]
|
||||
this.revive_times = 1;
|
||||
this.lastTimeStr = "";
|
||||
@@ -744,6 +720,8 @@ export class MissionComp extends CCComp {
|
||||
this.monsterCountSyncTimer = 0;
|
||||
this.lastPrepareCoinWave = 0;
|
||||
|
||||
spawningEngine.reset();
|
||||
|
||||
// 重置所有的战局得分数据,防止上一局的数据污染
|
||||
smc.resetScores();
|
||||
|
||||
@@ -786,7 +764,7 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.mission_data.level = wave;
|
||||
this.grantPrepareCoinByWave(wave);
|
||||
this.lastTimeSecond = -1;
|
||||
this.FightTime = FightSet.FiIGHT_TIME;
|
||||
this.clearTime = 0;
|
||||
this.update_time();
|
||||
|
||||
// 检查并推送卡池升级事件
|
||||
@@ -877,8 +855,17 @@ export class MissionComp extends CCComp {
|
||||
|
||||
// 怪物全灭检测:如果战斗阶段场上没有任何活着的怪物,直接结束战斗进入下一波的准备阶段
|
||||
if (monsterCount === 0 && smc.mission.play && !smc.mission.pause && this.currentPhase === MissionPhase.Battle) {
|
||||
this.FightTime = FightSet.FiIGHT_TIME;
|
||||
oops.message.dispatchEvent("TimeUpAdvanceWave");
|
||||
let heroesAliveRatio = heroCount / 6.0; // 假设最大 6 个站位,或者直接基于存活数算比例
|
||||
// 如果能获取当前已部署英雄数最好,这里简化处理,大于 4 个就算高存活
|
||||
heroesAliveRatio = Math.min(1.0, heroCount / 4.0);
|
||||
spawningEngine.updateAdaptive(heroesAliveRatio, this.clearTime);
|
||||
|
||||
if (this.currentWave >= 30) {
|
||||
// 30 波通关
|
||||
this.open_Victory(null, false);
|
||||
} else {
|
||||
oops.message.dispatchEvent("TimeUpAdvanceWave");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user