public IEnumerator SetBoost(float time) { GameObject newBar = Instantiate(powerBar); newBar.transform.parent = gameObject.transform; PowerBar newBarScript = newBar.GetComponent <PowerBar>(); newBarScript.SetPosition(); newBarScript.ChangeActive(true); newBarScript.SetColor(colorManager.GetColor("orange")); float time_left = time; while (time_left > 0) { m_currentSpeed_y = p_speed_y * (1 + p_boostPercentage / 100); m_currentSpeed_x = p_speed_x * (1 + p_boostPercentage / 100); time_left -= Time.deltaTime; newBarScript.SetFill(time_left / time); yield return(null); } m_currentSpeed_y = p_speed_y; m_currentSpeed_x = p_speed_x; newBarScript.DestroyBar(); }
public IEnumerator Overdrive(float time) { GameObject newBar = Instantiate(powerBar); PowerBar newBarScript = newBar.GetComponent <PowerBar>(); newBar.transform.parent = gameObject.transform; newBarScript.SetPosition(); m_overdrive = true; newBarScript.ChangeActive(true); newBarScript.SetColor(colorManager.GetColor("green")); colorManager.Cancel(); float time_left = time; float shotCD = 0; //Get Rainbow Scoop GameObject rainbowScoop = colorManager.GetRainbowScoop(); while (time_left > 0) { m_overdrive = true; time_left -= Time.deltaTime; newBarScript.SetFill(time_left / time); if (shotCD <= 0) { Shoot(rainbowScoop); shotCD = p_overdriveShotInterval; } else { shotCD -= Time.deltaTime; } yield return(null); } m_overdrive = false; newBarScript.DestroyBar(); }