Esempio n. 1
0
        private void ElapsedTimerAction(object sender, System.Timers.ElapsedEventArgs e)
        {
            lock (lockObj)
            {
                if (TimeRemainingWhite == 0 && OutOfTime != null)
                {
                    OutOfTime.Invoke(this, Base.Color.White);
                }

                if (TimeRemainingBlack == 0 && OutOfTime != null)
                {
                    OutOfTime.Invoke(this, Base.Color.Black);
                }

                var elapsed = Elapsed;
                if (Math.Abs(lastElapseUpdate - elapsed) >= 100 || (elapsed == 0 && lastElapseUpdate != 0))
                {
                    lastElapseUpdate = elapsed;
                    if (TimeRemainingChanged != null)
                    {
                        TimeRemainingChanged.Invoke(this);
                    }
                }
            }
        }
Esempio n. 2
0
    IEnumerator GameTimer()
    {
        while (_timeRemaining > 0)
        {
            yield return(new WaitForSeconds(1));

            _timeRemaining--;
            TimeRemainingChanged?.Invoke(_timeRemaining);
        }

        EndGame();
    }
Esempio n. 3
0
        protected override void OnUpdate(GameTime gameTime)
        {
            TimeRemaining = Interval - CurrentTime;
            TimeRemainingChanged.Raise(this, EventArgs.Empty);

            if (CurrentTime >= Interval)
            {
                State         = TimerState.Completed;
                CurrentTime   = Interval;
                TimeRemaining = TimeSpan.Zero;
                Completed.Raise(this, EventArgs.Empty);
            }
        }