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/GameController.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/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; } |