diff --git a/MuseumGame/Assets/Scripts/GameManager.cs b/MuseumGame/Assets/Scripts/GameManager.cs index 5a5b661..c7b39c1 100644 --- a/MuseumGame/Assets/Scripts/GameManager.cs +++ b/MuseumGame/Assets/Scripts/GameManager.cs @@ -144,7 +144,14 @@ public class GameManager : MonoBehaviour if (obtainedPowerups.Contains(Powerup.Shrink)) { - + if (Input.GetKeyDown("2") && !player.GetComponent().isShrunk) + { + player.GetComponent().startShrinking(); + } + if (Input.GetKeyDown("2") && player.GetComponent().isShrunk) + { + player.GetComponent().startUnShrinking(); + } } } diff --git a/MuseumGame/Assets/Scripts/Shrink.cs b/MuseumGame/Assets/Scripts/Shrink.cs index 87e1051..b9aeeda 100644 --- a/MuseumGame/Assets/Scripts/Shrink.cs +++ b/MuseumGame/Assets/Scripts/Shrink.cs @@ -5,9 +5,8 @@ using UnityEngine; public class Shrink : MonoBehaviour { private GameObject player; - private CapsuleCollider2D hitbox; - private bool canShrink = false; - private float timer = 0; + private bool canUnShrink = true; + public bool isShrunk = true; // Start is called before the first frame update void Start() { @@ -17,12 +16,12 @@ public class Shrink : MonoBehaviour // Update is called once per frame void Update() { - timer += Time.deltaTime; + } public void startShrinking() { - if (canShrink) + if (canUnShrink) { for(int i = 0; i < 3; i++) { @@ -35,7 +34,7 @@ public class Shrink : MonoBehaviour public void startUnShrinking() { - if (canShrink) + if (canUnShrink) { for(int i = 0; i<3; i++) { @@ -48,11 +47,11 @@ public class Shrink : MonoBehaviour private void OnTriggerEnter2D(Collider2D collision) { - canShrink = false; + canUnShrink = false; } private void OnTriggerExit2D(Collider2D collision) { - canShrink = true; + canUnShrink = true; } } diff --git a/MuseumGame/Assets/Scripts/movement.cs b/MuseumGame/Assets/Scripts/movement.cs index 5c6591f..472a20a 100644 --- a/MuseumGame/Assets/Scripts/movement.cs +++ b/MuseumGame/Assets/Scripts/movement.cs @@ -125,9 +125,12 @@ public class movement : MonoBehaviour private void OnCollisionEnter2D(Collision2D collision) { - numJumps = maxJumps; - isGrounded = true; - Debug.Log("Able to Jump"); + if(collision.gameObject.tag == "Floor") + { + numJumps = maxJumps; + isGrounded = true; + Debug.Log("Able to Jump"); + } } private void JumpAnimation()