Esempio n. 1
0
        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            //_timer.Stop();
            //_ballonNotifier.Notify("Current Activity", "What are you doing?");

            OnTimerElapsed?.Invoke(this, null);
        }
        /// <summary>
        /// The logic behind the countdown
        /// </summary>
        /// <param name="Duration">Starting time for the interval</param>
        /// <returns>Enumerator for yield</returns>
        protected override IEnumerator TimerFunctionality(float Duration)
        {
            float timerInterval = TimerInterval;

            currentInterval = Duration;
            OnIntervalElapsed.SafeInvoke(currentInterval);

            while (currentInterval > 0f)
            {
                float timeToWait = timerInterval;

                if (currentInterval < timerInterval)
                {
                    timeToWait = currentInterval;
                }

                if (UseWaitSecondsRealTime)
                {
                    yield return(new WaitForSecondsRealtime(timeToWait));
                }
                else
                {
                    yield return(new WaitForSeconds(timeToWait));
                }

                currentInterval -= timeToWait;

                OnIntervalElapsed.SafeInvoke(currentInterval);
            }

            OnTimerElapsed.SafeInvoke();
            timerCoroutine = null;
        }
Esempio n. 3
0
        private void Update()
        {
            if (!isRunning)
            {
                return;
            }

            float timePassed = Time.deltaTime;

            if (UseWaitSecondsRealTime)
            {
                timePassed = Time.unscaledDeltaTime;
            }

            currentInterval -= timePassed;
            intervalCounter += timePassed;

            if (currentInterval < 0f)
            {
                currentInterval = 0f;
            }

            if (intervalCounter >= TimerInterval)
            {
                OnIntervalElapsed.SafeInvoke(currentInterval);
                intervalCounter = 0f;
            }

            if (currentInterval <= 0f)
            {
                OnTimerElapsed.SafeInvoke();
                isRunning = false;
            }
        }
Esempio n. 4
0
 private void OnTick()
 {
     if (StartTime == null)
     {
         return;
     }
     OnTimerElapsed?.Invoke(StartTime.Value - DateTime.Now);
 }
Esempio n. 5
0
            /// <summary>
            /// Timer Elapsed Method
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                if (Elapsed < pv)
                {
                    Q = false;
                }
                else if (!Q)
                {
                    OnOutputSetTrue?.Invoke();
                    Q = true;
                }

                Elapsed += 1;
                OnTimerElapsed?.Invoke(sender, e);
            }
Esempio n. 6
0
    public void Tick(float deltaTime)
    {
        if (_paused || _elapsed)
        {
            return;
        }

        _timeLeft -= deltaTime;
        OnTimerTick?.Invoke(_timeLeft);

        if (!_elapsed && _timeLeft < 0)
        {
            _elapsed = true;
            OnTimerElapsed?.Invoke();
        }
    }
Esempio n. 7
0
 public void Update(float absoluteTime)
 {
     if (!Enabled)
     {
         lastElapsedTime = absoluteTime;
         elapsedTime     = 0.0f;
         return;
     }
     elapsedTime = absoluteTime - lastElapsedTime;
     if (elapsedTime > Interval)
     {
         OnTimerElapsed?.Invoke(absoluteTime);
         lastElapsedTime = absoluteTime;
         elapsedTime     = 0.0f;
         ++Count;
     }
 }
Esempio n. 8
0
 internal void SystemEvents_TimerElapsed(object sender, TimerElapsedEventArgs e)
 {
     OnTimerElapsed?.Invoke(sender, e);
 }