public void StartCooldown(string stateName) { AbilityCooldown value; if (abilityCooldowns.TryGetValue(stateName, out value)) { CooldownCompleteCallbackDelegate callback = new CooldownCompleteCallbackDelegate(CooldownComplete); IEnumerator callbackTimer = CallbackTimer(callback, abilityCooldowns[stateName].duration, stateName); StartCoroutine(callbackTimer); callbackTimers.Add(callbackTimer); abilityCooldowns[stateName].onCooldown = true; } if (stateName == "DashState") { sr.color = Color.gray; } }
IEnumerator CallbackTimer(CooldownCompleteCallbackDelegate callback, float duration, string stateName) { yield return(new WaitForSeconds(duration)); callback(stateName); }