Exemple #1
0
    private IEnumerator StartTimer()
    {
        while (_timeLeft > 0 && _timeLeft < maxTime && !_paused)
        {
            _timeLeft    -= Time.deltaTime;
            _slider.value = Mathf.Lerp(0f, 1f, _timeLeft / maxTime);

            yield return(null);
        }

        if (_timeLeft <= 0f)
        {
            ReachedZero?.Invoke();
        }
        else if (_timeLeft >= maxTime)
        {
            ReachedMax?.Invoke();
        }
    }
Exemple #2
0
 /// <summary>
 ///     Raises the countdown reached zero event.
 /// </summary>
 private void RaiseReachedZeroEvent()
 {
     ReachedZero?.Invoke(this, EventArgs.Empty);
 }