From 13b102b0055d1780255d083f01ae5672ccc7ade7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 13 Jun 2021 00:40:11 -0400 Subject: Airhorn at game end, better dribble, ball hit sound --- Assets/Scripts/Controllers/Ball.cs | 3 +++ Assets/Scripts/Controllers/GameController.cs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Assets/Scripts') 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(); 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}"); -- cgit v1.2.3-56-ge451 From 853b013d3c0127fb2c04a7cfeab23c77d52fc51f Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 13 Jun 2021 00:51:49 -0400 Subject: Hold ball away from face --- Assets/Scripts/Controllers/AIController.cs | 4 ++-- Assets/Scripts/Controllers/Player/PlayerController.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Assets/Scripts') diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs index cdfc9a8..a7de4fb 100644 --- a/Assets/Scripts/Controllers/AIController.cs +++ b/Assets/Scripts/Controllers/AIController.cs @@ -95,10 +95,10 @@ namespace Controllers flipper.transform.localScale = new Vector3(1f, 1f, 1f); else flipper.transform.localScale = new Vector3(-1f, 1f, 1f); + + game.enemy.Move(transform.position + new Vector3(0f, BoxCollider.size.y * 3/4, 0f) + (transform.right * (0.5f * (turn && currentTurn ? -1 : 1)))); turn = currentTurn; - game.enemy.Move(transform.position + new Vector3(0f, BoxCollider.size.y * 3/4, 0f)); - leftLeg.top.transform.localRotation = Quaternion.Euler(0, 0, maxLegAngle * Mathf.Sin(animationStep * legSpeed)); leftLeg.bottom.transform.localRotation = Quaternion.Euler(0, 0, maxLegAngle + maxLegAngle * Mathf.Sin(animationStep * legSpeed)); rightLeg.top.transform.localRotation = Quaternion.Euler(0, 0, maxLegAngle * Mathf.Sin(animationStep * -legSpeed)); diff --git a/Assets/Scripts/Controllers/Player/PlayerController.cs b/Assets/Scripts/Controllers/Player/PlayerController.cs index 9df8c0a..134abdc 100644 --- a/Assets/Scripts/Controllers/Player/PlayerController.cs +++ b/Assets/Scripts/Controllers/Player/PlayerController.cs @@ -81,7 +81,7 @@ namespace Controllers.Player if (segment.isTop) { - game.player.Move(segment.transform.position); + game.player.Move(segment.transform.position + segment.transform.right * (0.5f * (root.Rigidbody.velocity.x > 0.01f ? 1 : -1))); // Point the arms at the ball. segment.left.arm.transform.up = -(game.ball.transform.position - segment.left.arm.transform.position); -- cgit v1.2.3-56-ge451