fix:修复体力恢复倒计时出现负数的问题

This commit is contained in:
2026-07-15 11:49:16 +08:00
parent 447f311e39
commit 90d1f17df6
15 changed files with 320 additions and 302 deletions
@@ -105,8 +105,13 @@ export class LocalSaveMgr extends Component {
}
getPowerCD() {
let passTime = (Date.now() - this.playerData.lastAddPowerTimer) / 1000
return Config.powerCD - passTime
const lastAddPowerTimer = this.playerData.lastAddPowerTimer
if (!Number.isFinite(lastAddPowerTimer) || lastAddPowerTimer <= 0) {
return Config.powerCD
}
const passTime = Math.max(0, (Date.now() - lastAddPowerTimer) / 1000)
return Math.max(0, Config.powerCD - passTime)
}
protected update(dt: number): void {
+1 -2
View File
@@ -113,8 +113,7 @@ export class MainPanel extends PanelBase {
protected update(dt: number): void {
if (LocalSaveMgr.instance.playerData.isOnTimerRun) {
let totalSeconds = Math.ceil(LocalSaveMgr.instance.getPowerCD())
totalSeconds = Math.ceil(totalSeconds);
const totalSeconds = Math.max(0, Math.ceil(LocalSaveMgr.instance.getPowerCD()))
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds % 60;