예제 #1
0
    private void Update()
    {
        float         deltaTime = Time.deltaTime;
        List <string> dones     = new List <string>();

        if (removeAll == true)
        {
            Timers.Clear();
            this.removeAll = false;
        }

        foreach (string timerKey in Timers.Keys)
        {
            TimerWrapper wrapper = Timers[timerKey];
            if (wrapper.TimeIsUp())
            {
                wrapper.DoTask();
                dones.Add(timerKey);
            }
            else
            {
                wrapper.UpdateTime(deltaTime);
            }
        }

        foreach (string done in dones)
        {
            Timers.Remove(done);
        }
    }
예제 #2
0
    private void Update()
    {
        float         deltaTime = Time.deltaTime;
        List <string> dones     = new List <string>();

        foreach (string timerKey in Timers.Keys)
        {
            TimerWrapper wrapper = Timers[timerKey];
            if (stopExecution)
            {
                dones.Add(timerKey);
            }
            else if (wrapper.TimeIsUp())
            {
                if (!stopExecution)
                {
                    wrapper.DoTask();
                }
                dones.Add(timerKey);
            }
            else
            {
                wrapper.UpdateTime(deltaTime);
            }
        }

        foreach (string done in dones)
        {
            Timers.Remove(done);
        }
    }
예제 #3
0
        /// <summary>
        /// run all timer
        /// </summary>
        /// <param name="gameTime">time delly</param>
        public void Update(GameTime gameTime)
        {
            float         deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
            List <string> dones     = new List <string>();

            foreach (string timerKey in Timers.Keys)
            {
                TimerWrapper wrapper = Timers[timerKey];
                if (wrapper.TimeIsUp())
                {
                    wrapper.DoTask();
                    dones.Add(timerKey);
                }
                else
                {
                    wrapper.UpdateTime(deltaTime);
                }
            }

            foreach (string done in dones)
            {
                Timers.Remove(done);
            }
        }