Example #1
0
        public Clock(TimeSource source)
        {
            m_active    = false;
            m_time      = 0;
            m_speed     = 1.0f;
            m_elapsedMS = 0;

            m_source = source;
        }
Example #2
0
 public virtual void Tick(TimeSource source, float time)
 {
     if (m_active)
     {
         m_elapsedMS = m_speed * time;
         m_time     += m_speed * time;
     }
     else
     {
         m_elapsedMS = 0;
     }
 }
Example #3
0
        public override void Tick(TimeSource source, float timeMS)
        {
            base.Tick(source, timeMS);

            if (Speed > 0 && TimeMS > m_targetTimeMS || Speed < 0 && TimeMS < m_targetTimeMS)
            {
                if (OnTime != null)
                {
                    OnTime(this);
                }

                if (m_behaviour == TimerBehaviour.Restart)
                {
                    Reset();
                }
                else if (m_behaviour == TimerBehaviour.Stop)
                {
                    Stop();
                }
            }
        }
Example #4
0
        public Engine()
        {
            m_instance   = this;
            m_started    = false;
            m_components = new List <IEngineComponent>();

            m_random = new System.Random();

            m_timeSource     = new TimeSource();
            m_gameTimeSource = new TimeSource();

            m_realTime = new Clock(m_timeSource);
            m_realTime.Start();

            m_gameTime = new Clock(m_gameTimeSource);
            m_gameTime.Start();

            m_targetFrameTimeMS = 16.6f;

            m_frameRate          = new SmoothValue(1000 / m_targetFrameTimeMS, 0.9f);
            m_frameRate.Strength = 0.9f;

            Init();
        }
Example #5
0
 public Timer(TimeSource source, float targetTimeMS, TimerBehaviour behaviour)
     : base(source)
 {
     m_behaviour    = behaviour;
     m_targetTimeMS = targetTimeMS;
 }
Example #6
0
 public Timer(TimeSource source, float targetTimeMS)
     : this(source, targetTimeMS, TimerBehaviour.Stop)
 {
 }