]> git.cameronkatri.com Git - gmtk-gamejam.git/blobdiff - Assets/Scripts/Controllers/Hoop.cs
Add VFX
[gmtk-gamejam.git] / Assets / Scripts / Controllers / Hoop.cs
index 39c7a6f3d981bb6be1b67774fa048aaf982739c2..488c38b9b4eef989847742359eb3ff4b81270fe8 100644 (file)
@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace Controllers
 {
+       [RequireComponent(typeof(AudioSource))]
        [RequireComponent(typeof(AudioSource))]
        public class Hoop : MonoBehaviour
        {
@@ -11,6 +12,7 @@ namespace Controllers
                [SerializeField] private BoxCollider2D Rim;
                [SerializeField] private BoxCollider2D Net;
                [SerializeField] private AudioSource shotSound;
+               [SerializeField] private AudioSource crowdSound;
 
                private Animator HoopAnimator;
 
@@ -20,7 +22,8 @@ namespace Controllers
                {
                        if (other.GetComponent<Ball>() == null) return;
 
-                       if (Rim.IsTouching(other) && Net.IsTouching(other))
+                       // We don't want people shooting up the hoop so check the velocity of the ball to make sure it is going down.
+                       if (Rim.IsTouching(other) && Net.IsTouching(other) && (other.GetComponent<Rigidbody2D>().velocity.y < 0))
                        {
                                HoopAnimator.Rebind();
                                shotSound.Play();
@@ -28,6 +31,7 @@ namespace Controllers
                                        controller.player.Score(Rim.transform.position);
                                else if (this == controller.EnemyHoop)
                                        controller.enemy.Score(Rim.transform.position);
+                               crowdSound.Play();
                        }
                }
        }