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 {