]> git.cameronkatri.com Git - gmtk-gamejam.git/blob - Assets/Scripts/Controllers/Hoop.cs
Refine AI decision-making
[gmtk-gamejam.git] / Assets / Scripts / Controllers / Hoop.cs
1 using System;
2 using UnityEngine;
3
4 namespace Controllers
5 {
6 [RequireComponent(typeof(AudioSource))]
7 public class Hoop : MonoBehaviour
8 {
9 internal GameController controller;
10
11 [SerializeField] private BoxCollider2D Rim;
12 [SerializeField] private BoxCollider2D Net;
13 [SerializeField] private AudioSource shotSound;
14
15 private void OnTriggerEnter2D(Collider2D other)
16 {
17 if (other.GetComponent<Ball>() == null) return;
18
19 if (Rim.IsTouching(other) && Net.IsTouching(other))
20 {
21 shotSound.Play();
22 if (this == controller.PlayerHoop)
23 controller.player.Score(Rim.transform.position);
24 else if (this == controller.EnemyHoop)
25 controller.enemy.Score(Rim.transform.position);
26 }
27 }
28 }
29 }