private IEnumerator CoolDown() { float currentCharge = 0.0f; while (currentCharge < currentBoosterPrefab.m_CoolDownTime) { currentCharge += Time.deltaTime; float percentage = currentCharge / currentBoosterPrefab.m_CoolDownTime; // change boost loading UI to mirror numbers BoostLoading boostLoading = GameMaster.Instance.m_UIManager.m_BoostLoading; if (boostLoading != null) { boostLoading.SetPercentage(percentage); } yield return(null); } // NOW CAN USE BOOSTER! canActivate = true; // set boost image to current booster image BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading; boostLoadingUI.SetBoostSprite(currentBoosterPrefab.m_UISprite); boostLoadingUI.SetPercentage(100.0f); }
public void Reset() { // if we have a booster prefab that is equipped on player if (currentBoosterPrefab != null) { // stop possible coroutines that could still be running StopCoroutine("StartBoostDurationCountdown"); StopCoroutine("CoolDown"); StopCoroutine("ActivateCurrentBooster"); // allow the boost to be reset and active BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading; boostLoadingUI.SetPercentage(100.0f); canActivate = true; // destroy previous instance of boost is there was one if (currentBoosterInstance != null) { Destroy(currentBoosterInstance.gameObject); } } }