From 40471cf464366a7f49110a31d00fec160856b60f Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sat, 12 Jun 2021 18:41:18 -0400 Subject: Add sound effects for dribble and shoot --- Assets/Scripts/Controllers/Hoop.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Assets/Scripts/Controllers/Hoop.cs') 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() == 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 -- cgit v1.2.3