aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-06-13 00:40:11 -0400
committerCameron Katri <me@cameronkatri.com>2021-06-13 00:40:11 -0400
commit13b102b0055d1780255d083f01ae5672ccc7ade7 (patch)
tree62384af69389ca7cabe7b4cfa534ef401bcdae6f /Assets/Scripts
parentaf13ca7f36f617c95e3932bb3282e7a5ffa8d2fe (diff)
downloadgmtk-gamejam-13b102b0055d1780255d083f01ae5672ccc7ade7.tar.gz
gmtk-gamejam-13b102b0055d1780255d083f01ae5672ccc7ade7.tar.zst
gmtk-gamejam-13b102b0055d1780255d083f01ae5672ccc7ade7.zip
Airhorn at game end, better dribble, ball hit sound
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/Controllers/Ball.cs3
-rw-r--r--Assets/Scripts/Controllers/GameController.cs6
2 files changed, 8 insertions, 1 deletions
diff --git a/Assets/Scripts/Controllers/Ball.cs b/Assets/Scripts/Controllers/Ball.cs
index ae0656f..01d9bf4 100644
--- a/Assets/Scripts/Controllers/Ball.cs
+++ b/Assets/Scripts/Controllers/Ball.cs
@@ -9,12 +9,15 @@ namespace Controllers
internal GameController controller;
[SerializeField] private float shotForce;
+ [SerializeField] private AudioSource ballHitSound;
+ [SerializeField] private AudioClip ballHitClip;
public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
private Rigidbody2D _rigidbody;
private void OnCollisionEnter2D(Collision2D other)
{
+ ballHitSound.PlayOneShot(ballHitClip);
controller.BallDropped();
}
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 4bdae38..62bb849 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -37,6 +37,7 @@ namespace Controllers
[Header("SFX")]
[SerializeField] public AudioSource dribbleSound;
+ [SerializeField] public AudioSource airhornSound;
[Header("UI")]
[SerializeField] private Text playerScoreText;
@@ -66,6 +67,7 @@ namespace Controllers
UpdateUI();
}
+ private bool gameover;
private void UpdateUI()
{
playerScoreText.text = $"{player.score}";
@@ -75,8 +77,10 @@ namespace Controllers
var remaining = TimeSpan.FromSeconds(Mathf.Clamp(remainingRaw, 0, float.MaxValue));
timerText.text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
- if (remainingRaw <= 0)
+ if (remainingRaw <= 0 && !gameover)
{
+ gameover = true;
+ airhornSound.Play();
var outcome = player.score == enemy.score ? "TIE GAME" : player.score < enemy.score ? "AWAY TEAM WINS" : "HOME TEAM WINS";
ShowModal($"{outcome}\n{player.score}-{enemy.score}");