/// <summary> /// Move /// </summary> private void FixedUpdate() { //Check freezen if (timeToUnfrozen == 0) { //Check input var input = Input.GetAxis("Horizontal"); if (input != 0) { //Calculate new position var targetPosition = new Vector2 { x = rb2d.position.x + (input * ConfigurationUtils.PaddleMoveUnitsPerSecond * Time.fixedUnscaledDeltaTime), y = frozenPositionY }; //Apply new position rb2d.MovePosition(targetPosition); } } else { timeToUnfrozen -= (UFloat)Time.fixedUnscaledDeltaTime; if (timeToUnfrozen == 0) { AudioManager.Play(AudioName.EffectFreezerDeactivated); } //Activate the animation for unfreezing if (timeToUnfrozen < 0.5f) //0.5f it's the current duration of the animation { animator.SetBool("IsFreezing", false); } } }
private void FreezerEffectActivated(float freezerEffectDuration) { timeToUnfrozen += (UFloat)freezerEffectDuration; //Activate the animation for freezing animator.SetBool("IsFreezing", true); }
private void SpeedupEffectActivated(float duration, float force) { if (Time.timeScale == 1) { Time.timeScale *= force; } timeToNormalSpeed += (UFloat)duration; }
private void Update() { //Check time to normal speed if (timeToNormalSpeed != 0 && !PauseWaiter.IsPauseMod()) { timeToNormalSpeed -= (UFloat)Time.unscaledDeltaTime; //Stop speedupEffect, if it is the time if (timeToNormalSpeed == 0 && !EndGameWaiter.IsGameOver()) { AudioManager.Play(AudioName.EffectSpeedupDeactivated); Time.timeScale = 1; } } }