fix:修复体力恢复倒计时出现负数的问题
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user