using System.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TinyCountDown :Singleton { private Dictionary m_CountDown = new Dictionary(); public TinyCountDown() { } public void Set(string key, float time) { if (!m_CountDown.ContainsKey(key)) { m_CountDown.Add(key, time); } else { m_CountDown[key] = time; } } public float Get(string key) { if (m_CountDown.ContainsKey(key)) { return m_CountDown[key]; } return 0; } public void Update() { List keys = new List(m_CountDown.Keys); foreach (var key in keys) { m_CountDown[key] -= Time.deltaTime; if(m_CountDown[key] <= 0) { m_CountDown.Remove(key); } } } }