diff options
author | Carson Katri <carson.katri@gmail.com> | 2021-06-13 01:07:23 -0400 |
---|---|---|
committer | Carson Katri <carson.katri@gmail.com> | 2021-06-13 01:07:23 -0400 |
commit | fb098531f41a3314ac61f1e4c808625c679c4653 (patch) | |
tree | 8cb1e06196893292166b2908b6112d921852d9d6 /Assets/Scripts | |
parent | f2ea922dfd57bdbd64a0091eab3b97f936281343 (diff) | |
parent | 853b013d3c0127fb2c04a7cfeab23c77d52fc51f (diff) | |
download | gmtk-gamejam-fb098531f41a3314ac61f1e4c808625c679c4653.tar.gz gmtk-gamejam-fb098531f41a3314ac61f1e4c808625c679c4653.tar.zst gmtk-gamejam-fb098531f41a3314ac61f1e4c808625c679c4653.zip |
Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam
Diffstat (limited to 'Assets/Scripts')
-rw-r--r-- | Assets/Scripts/Controllers/AIController.cs | 4 | ||||
-rw-r--r-- | Assets/Scripts/Controllers/Ball.cs | 3 | ||||
-rw-r--r-- | Assets/Scripts/Controllers/GameController.cs | 6 | ||||
-rw-r--r-- | Assets/Scripts/Controllers/Player/PlayerController.cs | 2 |
4 files changed, 11 insertions, 4 deletions
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/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 739f76c..404a755 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}"); 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); |