Esempio n. 1
0
        public override void Update(GameTime gameTime)
        {
            List <FlxTimer> loopedTimers = null;
            float           elapsed      = (float)gameTime.ElapsedGameTime.TotalSeconds;

            foreach (FlxTimer timer in _timers)
            {
                if (timer.Active && !timer.Finished && timer.Time >= 0)
                {
                    int timerLoops = timer.ElapsedLoops;
                    timer.Update(elapsed);

                    if (timerLoops != timer.ElapsedLoops)
                    {
                        if (loopedTimers == null)
                        {
                            loopedTimers = new List <FlxTimer>();
                        }

                        loopedTimers.Add(timer);
                    }
                }
            }

            if (loopedTimers != null)
            {
                while (loopedTimers.Count > 0)
                {
                    FlxTimer timer = loopedTimers[0];
                    loopedTimers.Remove(timer);
                    timer.OnLoopFinished();
                }
            }
            base.Update(gameTime);
        }
Esempio n. 2
0
 public void Remove(FlxTimer timer)
 {
     _timers.Remove(timer);
 }
Esempio n. 3
0
 public void Add(FlxTimer timer)
 {
     _timers.Add(timer);
 }