コード例 #1
0
    /// <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);
        }
    }
コード例 #2
0
ファイル: Countdown.cs プロジェクト: NicholasBarham/pong-3d
        public void Tick(float amount)
        {
            if (IsComplete)
            {
                return;
            }

            CurrentTime -= Math.Abs(amount);

            if (CurrentTime <= 0f)
            {
                CurrentTime = 0f;
                IsComplete  = true;
                OnCountdownComplete?.Invoke();
            }

            OnCountdownTick?.Invoke(CurrentTime);
        }