diff options
Diffstat (limited to 'Assets/Scripts/Controllers/GameController.cs')
-rw-r--r-- | Assets/Scripts/Controllers/GameController.cs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs index 8dd6fc4..54a0425 100644 --- a/Assets/Scripts/Controllers/GameController.cs +++ b/Assets/Scripts/Controllers/GameController.cs @@ -21,11 +21,15 @@ namespace Controllers [SerializeField] public Hoop PlayerHoop; [SerializeField] public Hoop EnemyHoop; + [SerializeField] public AudioSource dribbleSound; + private void Awake() { player = new Player { isEnemy = false, controller = this }; enemy = new Player { isEnemy = true, controller = this }; ball.controller = this; + PlayerHoop.controller = this; + EnemyHoop.controller = this; } public struct Player @@ -88,6 +92,7 @@ namespace Controllers if (Vector2.Distance(controller.ball.transform.position, handPosition) >= 1f) return false; controller.state = dribble; + controller.dribbleSound.Play(); Move(handPosition); return true; } @@ -100,6 +105,7 @@ namespace Controllers public bool Shoot(Transform playerTransform) { if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it. + controller.dribbleSound.Stop(); controller.state = shoot; controller.ball.Shoot(hoop.transform.position); lastShotPosition = playerTransform.position; @@ -109,6 +115,7 @@ namespace Controllers internal void BallDropped() { + dribbleSound.Stop(); state = State.Idle; } |