diff --git a/Assets/Scripts/Birb/Jump.cs b/Assets/Scripts/Birb/Jump.cs index cf199ab85477d68bfa73f989463e5d0e58a93bd8..bce02f4237d75e1439dd1a3c6a27a75e70b6d3fa 100644 --- a/Assets/Scripts/Birb/Jump.cs +++ b/Assets/Scripts/Birb/Jump.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine; using System.Collections; using System.Collections.Generic; @@ -14,7 +15,6 @@ public class Jump : AbstractBehavior { get{return jumpRequested;} } bool jumpRequested; - bool jumpBlocked; int airJumpsMade = 0; Walk walk; @@ -27,6 +27,8 @@ public class Jump : AbstractBehavior { void Update() { if (!jumpRequested && inputState.GetButtonPressed(inputButtons[0])) { jumpRequested = true; + if(jumpHeight==0) + animator.SetTrigger("jump failed"); } float jumpState; Vector2 vel = body.velocity; @@ -36,7 +38,7 @@ public class Jump : AbstractBehavior { jumpState = 0; } jumpState = Mathf.Sqrt(jumpState); - animator.SetFloat("jump state", jumpState); + animator.SetFloat ("jump state", jumpState); // reset air jumps when on ground if (collisionState.onGround) { airJumpsMade = 0; @@ -44,7 +46,7 @@ public class Jump : AbstractBehavior { } void FixedUpdate() { - if (jumpRequested) { + if (jumpRequested) { Activate(); jumpRequested = false; } @@ -53,11 +55,6 @@ public class Jump : AbstractBehavior { public void Activate() { if (collisionState.onGround) { // ground jump -<<<<<<< HEAD - - airJumpsMade = 0; -======= ->>>>>>> d984067ea55e6a0191c6cb7033212e7268955de1 Vector2 vel = body.velocity; vel.y = GetJumpVelocity(jumpHeight); body.velocity = vel; @@ -89,8 +86,9 @@ public class Jump : AbstractBehavior { return Mathf.Sqrt(-2 * gravity * height); } - void OnCollisionEnter2D(Collision2D other) - { - airJumpsMade = 0; - } -} + void OnCollisionEnter2D(Collision2D other) + { + airJumpsMade = 0; + } + +} \ No newline at end of file diff --git a/Assets/Scripts/Util/HazardSlow.cs b/Assets/Scripts/Util/HazardSlow.cs index 35d2f3b0fe91c8809dd3d2f3a40f94689f160706..8537d4a5ded92ef1e61e5fc750f5b6bd32ef289d 100644 --- a/Assets/Scripts/Util/HazardSlow.cs +++ b/Assets/Scripts/Util/HazardSlow.cs @@ -6,10 +6,15 @@ public class HazardSlow : AbstractBehavior { //Remember to give prefabs that have this script a "slowHazard" tag. float slowfactor; public float slowedSpeed; + float jumpHeightHold; //Holds the jumpHeight current value. + float wallJumpHeightHold; //Holds the wallJumpHeight current value. + bool valuesHeld; void Awake() { slowfactor = 2.0f; + valuesHeld = false; + } void OnTriggerEnter2D(Collider2D other){ @@ -17,7 +22,15 @@ public class HazardSlow : AbstractBehavior { if(other.tag=="Player"){ other.GetComponent().speed /= slowfactor; - other.GetComponent ().enabled = false; + //other.GetComponent ().enabled = false; + if (!valuesHeld) { + jumpHeightHold = other.GetComponent ().jumpHeight; + wallJumpHeightHold = other.GetComponent ().wallJumpHeight; + valuesHeld = true; + } + other.GetComponent ().jumpHeight = 0; + other.GetComponent ().wallJumpHeight = 0; + } } void OnTriggerExit2D(Collider2D other){ @@ -25,7 +38,9 @@ public class HazardSlow : AbstractBehavior { if(other.tag=="Player"){ other.GetComponent().speed *= slowfactor; - other.GetComponent().enabled = true; + //other.GetComponent().enabled = true; + other.GetComponent ().jumpHeight = jumpHeightHold; + other.GetComponent ().wallJumpHeight = wallJumpHeightHold; } }