/// <summary> /// Bost mechanic. The player accumulates /// speed whilist the secondary button in /// the mouse is hold clicked. Until the button /// is released, the player will reduced the /// speed, but that speed will be accumulated /// and the more the player accumulates, the longer /// the boost will be. Player speed boost will be max /// speed and then after the boost time is done the speed /// will be gradually recovered. /// </summary> private IEnumerator ReduceSpeed() { float uiSpeed = 0f; canBoost = false; // stop dust animation. playerModel.StopDust(); // display accumulate energy animation. playerModel.AccumulateSpeedAnimation(); // set accumulate energy soundclip. SetSoundClip(0); PlaySound(); // reduce speed and accumulate as long as the player holds the right button in the mouse. while (accumulating) { if (speed > 0f) { speed--; // Update UI speed value. SpeedValue.instance.TriggerUISpeedAction("maxReducer"); } UpdateSpeed(); yield return(new WaitForSeconds(boostAcummulationSpeed)); } // StopSound(); speed = maxSpeed; UpdateSpeed(); }