/// <summary> /// Performs the countdown procedure, but only updates /// itself every second that ticks down. /// </summary> private async void CountdownPerSecond() { int timeLeft = Mathf.CeilToInt(_warpCountdown); while (timeLeft-- > 0) { OnCountdownTick?.Invoke(this, new WarpCountdownArgs(timeLeft)); await Task.Delay(1000); } }
public void Tick(float amount) { if (IsComplete) { return; } CurrentTime -= Math.Abs(amount); if (CurrentTime <= 0f) { CurrentTime = 0f; IsComplete = true; OnCountdownComplete?.Invoke(); } OnCountdownTick?.Invoke(CurrentTime); }