aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/Hoop.cs
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-06-12 18:41:18 -0400
committerCameron Katri <me@cameronkatri.com>2021-06-12 18:41:18 -0400
commit40471cf464366a7f49110a31d00fec160856b60f (patch)
tree33f8f8ea1e6da3e2dbed8cd46b06e9bf5bb9cfbe /Assets/Scripts/Controllers/Hoop.cs
parenta524f24128a4653bbc06eede2379107f9255faf9 (diff)
downloadgmtk-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.cs14
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