Exemplo n.º 1
0
        /// <summary>
        /// Update the GameTimer and process events
        /// Called by the TimerManager by defualt
        ///
        /// Advanced: With the owner called update model, the owner must call this explicitly in its update
        /// </summary>
        public bool Update()
        {
            Debug.Assert(this.seconds >= 0.0);

            double elapsedTime = 0;

            if (this.clock == ClockType.WallClock)
            {
                elapsedTime = Time.WallClockTotalSeconds - startTime;
            }
            else
            {
                elapsedTime = Time.GameTimeTotalSeconds - startTime;
            }

            bool elapsed = elapsedTime >= seconds;

            if (elapsed)
            {
                this.state = State.Elapsed;
                GameTimerManager.DetachTimer(this);

                if (TimerElapsed != null)
                {
                    TimerElapsed(this);
                }
            }
            return(elapsed);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Stops the timer
 ///
 /// Advanced: should not be called for owner called update model
 /// </summary>
 public void Stop()
 {
     this.state = State.Paused;
     GameTimerManager.DetachTimer(this);
 }