Commit da640815 by Philipp Adolf

Only allow a single dash in the air

parent 26ecec69
...@@ -36,6 +36,8 @@ public class PlayerControl : MonoBehaviour ...@@ -36,6 +36,8 @@ public class PlayerControl : MonoBehaviour
public float dashCollisionCoolDown = 1.5f; public float dashCollisionCoolDown = 1.5f;
[HideInInspector] [HideInInspector]
public float currentDashCoolDown = 0.0f; public float currentDashCoolDown = 0.0f;
[HideInInspector]
public bool hasLandedSinceLastDash = true;
// public float jumpWaitTime = 2.0; // public float jumpWaitTime = 2.0;
[HideInInspector] [HideInInspector]
...@@ -109,6 +111,7 @@ public class PlayerControl : MonoBehaviour ...@@ -109,6 +111,7 @@ public class PlayerControl : MonoBehaviour
lastDashStart = Time.time; lastDashStart = Time.time;
currentDashDirection = dashDirection; currentDashDirection = dashDirection;
currentDashCoolDown = dashCoolDown; currentDashCoolDown = dashCoolDown;
hasLandedSinceLastDash = false;
} }
if (isDashing ()) if (isDashing ())
...@@ -118,6 +121,10 @@ public class PlayerControl : MonoBehaviour ...@@ -118,6 +121,10 @@ public class PlayerControl : MonoBehaviour
else else
{ {
bool grounded = isGrounded(); bool grounded = isGrounded();
if (grounded && !isDashing())
{
hasLandedSinceLastDash = true;
}
velocity = body2D.velocity; velocity = body2D.velocity;
if (Input.GetKey(keyCodes[(int)Keys.Right])) if (Input.GetKey(keyCodes[(int)Keys.Right]))
...@@ -222,7 +229,7 @@ public class PlayerControl : MonoBehaviour ...@@ -222,7 +229,7 @@ public class PlayerControl : MonoBehaviour
private bool canDash () private bool canDash ()
{ {
return getDashTime() >= dashCompletionTime + currentDashCoolDown; return hasLandedSinceLastDash && getDashTime() >= dashCompletionTime + currentDashCoolDown;
} }
/*==========Power Ups // Bullet management ===*/ /*==========Power Ups // Bullet management ===*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment