Merge remote-tracking branch 'refs/remotes/origin/devTestBranch'

This commit is contained in:
Niko Jochim 2020-07-02 12:54:22 +02:00
commit 66aa21ccb4

View File

@ -13,6 +13,7 @@ class RoundTimer: Timer {
var timer: Timer?
var timeLeft: Int = 0
var isHeartbeatLocked = false
var isTimerStopped = false
var calculate = false
var roundEnded = "Syncing"
@ -31,23 +32,16 @@ class RoundTimer: Timer {
}
func stopTimer() {
guard timer != nil else { return }
timer?.invalidate()
timer = nil
isTimerStopped = true
}
func resumeTimer() {
timer = Timer.scheduledTimer(
timeInterval: 1.0,
target: self,
selector: #selector(onTimerFires),
userInfo: nil,
repeats: true
)
isTimerStopped = false
}
@objc func onTimerFires()
{
if !isTimerStopped {
timeLeft -= 1
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
@ -75,4 +69,5 @@ class RoundTimer: Timer {
isHeartbeatLocked = true;
}
}
}
}