fix(mission): 修复波次更迭与战斗结束阶段的逻辑冲突
调整 PhaseTime 计时器间隔为 1 秒,避免更新过于频繁。 在 update 逻辑中,当游戏暂停且当前阶段不是 BattleEnd 时才完全停止,确保战斗结束动画能正常播放并自动流转。 修改波次更迭逻辑:新波次到来时先进入 BattleEnd 阶段,播放结束技能后自动进入准备阶段,避免与 open_Victory 的结算流程冲突。 在 open_Victory 中立即标记暂停,以切断波次自动流转。
This commit is contained in:
@@ -127,7 +127,7 @@ export class MissionComp extends CCComp {
|
||||
diamond:0
|
||||
}
|
||||
/**秒计时 */
|
||||
PhaseTime:Timer= new Timer(0.5)
|
||||
PhaseTime:Timer= new Timer(1)
|
||||
/** 上一次显示的时间字符串(避免重复设置) */
|
||||
private lastTimeStr: string = "";
|
||||
/** 上一次显示的秒数(避免重复计算) */
|
||||
@@ -194,7 +194,9 @@ export class MissionComp extends CCComp {
|
||||
*/
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play) return
|
||||
if(smc.mission.pause) return
|
||||
|
||||
// 如果是暂停状态,且不在 BattleEnd 阶段(全灭时需要播放完 fend 技能动画并自动流转),才真正停止 update 逻辑
|
||||
if(smc.mission.pause && this.currentPhase !== MissionPhase.BattleEnd) return
|
||||
|
||||
// 处理过渡阶段的计时
|
||||
if (this.currentPhase === MissionPhase.PrepareStart ||
|
||||
@@ -372,23 +374,28 @@ export class MissionComp extends CCComp {
|
||||
case MissionPhase.BattleEnd:
|
||||
// BattleEnd 计时结束后,如果是因为全灭或手动调用的 fight_end,进入 Settle
|
||||
// 需要注意的是,open_Victory / fight_end 现在只需切换到 BattleEnd 即可,Settle 由这里自动接管
|
||||
this.changePhase(MissionPhase.Settle);
|
||||
|
||||
// 此时已经经过了 2s,可以真正执行结算弹窗或清理逻辑
|
||||
if (smc.mission.play) {
|
||||
// 如果游戏还在运行中,说明是通过 open_Victory 进来的
|
||||
smc.mission.pause = true;
|
||||
mLogger.log(this.debugMode, 'MissionComp', " autoNextPhase -> open_Victory logic", this.revive_times);
|
||||
oops.gui.open(UIID.Victory, {
|
||||
victory: false,
|
||||
rewards: this.rewards,
|
||||
game_data: this.game_data,
|
||||
can_revive: this.revive_times > 0
|
||||
});
|
||||
// 如果游戏正在运行(波次更迭),则自动进入 PrepareStart 阶段
|
||||
if (smc.mission.play && !smc.mission.pause) {
|
||||
this.changePhase(MissionPhase.PrepareStart);
|
||||
} else {
|
||||
// 如果 play 已经是 false,说明是通过 fight_end 进来的
|
||||
this.cleanComponents();
|
||||
this.clearBattlePools();
|
||||
this.changePhase(MissionPhase.Settle);
|
||||
|
||||
// 此时已经经过了 2s,可以真正执行结算弹窗或清理逻辑
|
||||
if (smc.mission.play) {
|
||||
// 如果游戏还在运行中,说明是通过 open_Victory 进来的
|
||||
smc.mission.pause = true;
|
||||
mLogger.log(this.debugMode, 'MissionComp', " autoNextPhase -> open_Victory logic", this.revive_times);
|
||||
oops.gui.open(UIID.Victory, {
|
||||
victory: false,
|
||||
rewards: this.rewards,
|
||||
game_data: this.game_data,
|
||||
can_revive: this.revive_times > 0
|
||||
});
|
||||
} else {
|
||||
// 如果 play 已经是 false,说明是通过 fight_end 进来的
|
||||
this.cleanComponents();
|
||||
this.clearBattlePools();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -458,6 +465,8 @@ export class MissionComp extends CCComp {
|
||||
* @param is_hero_dead 是否因英雄全灭触发
|
||||
*/
|
||||
open_Victory(e:any,is_hero_dead: boolean = false){
|
||||
// 战斗失败或胜利,标记暂停状态以切断波次流转逻辑
|
||||
smc.mission.pause = true;
|
||||
// 直接切入 BattleEnd,触发 fend 表现
|
||||
// 倒计时逻辑已在 update 中由 PhaseTime 接管,2s 后将触发 autoNextPhase 弹窗结算
|
||||
this.changePhase(MissionPhase.BattleEnd);
|
||||
@@ -541,7 +550,10 @@ export class MissionComp extends CCComp {
|
||||
private onNewWave(event: string, data: any) {
|
||||
const wave = Number(data?.wave ?? 0);
|
||||
if (wave <= 0) return;
|
||||
this.enterPreparePhase();
|
||||
|
||||
// 在新一波到来时,先进入 BattleEnd,触发上一波的战斗结束技能 (fend),2秒后自动进入下一波的准备阶段
|
||||
this.changePhase(MissionPhase.BattleEnd);
|
||||
|
||||
this.currentWave = wave;
|
||||
smc.vmdata.mission_data.level = wave;
|
||||
this.grantPrepareCoinByWave(wave);
|
||||
|
||||
Reference in New Issue
Block a user