private IEnumerator UpdateCoroutine() { while (timeLeft > 0 && !isComplete) { yield return(null); _preTime = timeLeft; timeLeft = GetTimeLeft(); if (_preTime != timeLeft) { OnUpdate?.Invoke(timeLeft); } } if (isComplete) { yield break; } Debug.Log(GameTimers.TIMER + id + " Completed!"); isComplete = true; GameTimers.RemoveTimer(id); OnComplete?.Invoke(this); }
public void Stop() { Debug.Log(GameTimers.TIMER + id + " Stopped!"); StopCoroutine(myself); OnUpdate?.Invoke(0); isComplete = true; GameTimers.RemoveTimer(id); }
private long GetTimeLeft() { var time = endTime - GameTimers.GetNowTimestampSeconds(); return(time < 0 ? 0 : time); }