public static Cooldown Create(CooldownType type, int id, float cdTime) { GameObject go = new GameObject("Cooldown"); go.hideFlags = HideFlags.HideAndDontSave; Cooldown cooldown = go.AddComponent <Cooldown>(); cooldown.type = type; cooldown.id = id; cooldown.cdTime = cdTime; cooldown.startTime = Time.realtimeSinceStartup; return(cooldown); }
public void AddCooldown(CooldownType type, int id, float cdTime) { Cooldown cool = GetCooldown(type, id); if (cool != null) { cool.Dispose(); } cool = Cooldown.Create(type, id, cdTime); string key = type.ToString() + id; cooldownDict[key] = cool; if (OnCooldownChange != null) { OnCooldownChange(cool); } }