private void DoDash() { StopAllMovementCoroutines(true); // TODO dkonik: We are not using start position. But maybe we want to DashInformation info = stateManager.CurrentStateInformation_Exn <DashInformation>(); rb2d.velocity = info.Velocity; }
private void DashButtonReleased() { if (stateManager.CurrentState == State.ChargeDash) { DashInformation info = stateManager.GetStateInformationForWriting <DashInformation>(State.Dash); info.StartPosition = playerMovement.CurrentPosition; info.Velocity = (Quaternion.AngleAxis(playerMovement.CurrentRigidBodyRotation, Vector3.forward) * Vector3.right).normalized * dashSpeed * (1.0f + chargeAmount); stateManager.TransitionToState(State.Dash, info); } }
private IEnumerator Dash() { DashInformation information = stateManager.CurrentStateInformation_Exn <DashInformation>(); // TODO dkonik: Revisit this math, why do we do this? float dashDuration = Mathf.Min((information.Velocity.magnitude / dashSpeed) - 1f, 0.5f); AudioManager.instance.DashSound.Play(); // Set duration of particle system for each dash trail. // TODO dkonik: Do not instantiate every time dashEffect = Instantiate(dashEffectPrefab, playerMovement.CurrentPosition, playerMovement.CurrentRotation, transform); foreach (ParticleSystem ps in dashEffect.GetComponentsInChildren <ParticleSystem>()) { ps.Stop(); ParticleSystem.MainModule main = ps.main; main.duration = dashDuration; ps.Play(); } float startTime = Time.time; while (Time.time - startTime <= dashDuration) { yield return(null); } foreach (ParticleSystem ps in dashEffect.GetComponentsInChildren <ParticleSystem>()) { ps.Stop(); } stateManager.TransitionToState(State.NormalMovement); }