diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-06-12 18:41:18 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-06-12 18:41:18 -0400 |
commit | 40471cf464366a7f49110a31d00fec160856b60f (patch) | |
tree | 33f8f8ea1e6da3e2dbed8cd46b06e9bf5bb9cfbe /Assets/Scripts/Controllers/Hoop.cs | |
parent | a524f24128a4653bbc06eede2379107f9255faf9 (diff) | |
download | gmtk-gamejam-40471cf464366a7f49110a31d00fec160856b60f.tar.gz gmtk-gamejam-40471cf464366a7f49110a31d00fec160856b60f.tar.zst gmtk-gamejam-40471cf464366a7f49110a31d00fec160856b60f.zip |
Add sound effects for dribble and shoot
Diffstat (limited to 'Assets/Scripts/Controllers/Hoop.cs')
-rw-r--r-- | Assets/Scripts/Controllers/Hoop.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Assets/Scripts/Controllers/Hoop.cs b/Assets/Scripts/Controllers/Hoop.cs index 58f7130..5633743 100644 --- a/Assets/Scripts/Controllers/Hoop.cs +++ b/Assets/Scripts/Controllers/Hoop.cs @@ -3,17 +3,27 @@ using UnityEngine; namespace Controllers { + [RequireComponent(typeof(AudioSource))] public class Hoop : MonoBehaviour { + internal GameController controller; + [SerializeField] private BoxCollider2D Rim; [SerializeField] private BoxCollider2D Net; + [SerializeField] private AudioSource shotSound; private void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent<Ball>() == null) return; - + if (Rim.IsTouching(other) && Net.IsTouching(other)) - Debug.Log("Swish!"); + { + shotSound.Play(); + if (this == controller.PlayerHoop) + controller.player.Score(Rim.transform.position); + else if (this == controller.EnemyHoop) + controller.enemy.Score(Rim.transform.position); + } } } }
\ No newline at end of file |