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); } }
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); } }
/// <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); } }