aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts
diff options
context:
space:
mode:
authorCarson Katri <carson.katri@gmail.com>2021-06-13 01:34:54 -0400
committerCarson Katri <carson.katri@gmail.com>2021-06-13 01:34:54 -0400
commite22b3562a58baabf3d5c508637f59d8d516c2bad (patch)
tree2469a225c6ab5ed4add2ac7866676b6dcc48e9af /Assets/Scripts
parentfb098531f41a3314ac61f1e4c808625c679c4653 (diff)
downloadgmtk-gamejam-e22b3562a58baabf3d5c508637f59d8d516c2bad.tar.gz
gmtk-gamejam-e22b3562a58baabf3d5c508637f59d8d516c2bad.tar.zst
gmtk-gamejam-e22b3562a58baabf3d5c508637f59d8d516c2bad.zip
Add trenchcoat fadein
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/Controllers/GameController.cs38
1 files changed, 36 insertions, 2 deletions
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 404a755..f2e3283 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections;
using JetBrains.Annotations;
using UnityEngine;
+using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace Controllers
@@ -26,6 +27,8 @@ namespace Controllers
/// The single ball for the game.
/// </summary>
[SerializeField] public Ball ball;
+
+ [SerializeField] public SpriteRenderer[] trenchCoatSegments;
[Header("Spawn Points")]
[SerializeField] private SpawnPoints PlayerSpawnPoints;
@@ -46,6 +49,7 @@ namespace Controllers
[SerializeField] private GameObject resultOverlay;
[SerializeField] private Text resultText;
+ [SerializeField] private GameObject actionsUI;
private void Awake()
{
@@ -59,6 +63,27 @@ namespace Controllers
private void Start()
{
+ freezeMotion = true;
+ StartCoroutine(FadeInCoat());
+ }
+
+ private IEnumerator FadeInCoat()
+ {
+ foreach (var trenchCoat in trenchCoatSegments)
+ trenchCoat.material.color = new Color(1, 1, 1, 0);
+
+ yield return new WaitForSeconds(1f);
+
+ for (float t = 0; t < 1f; t += Time.deltaTime / 1)
+ {
+ foreach (var trenchCoat in trenchCoatSegments)
+ trenchCoat.material.color = new Color(1, 1, 1, Mathf.Lerp(0, 1, t));
+ yield return null;
+ }
+
+ yield return new WaitForSeconds(1f);
+
+ freezeMotion = false;
startTime = Time.time;
}
@@ -79,12 +104,13 @@ namespace Controllers
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";
+ actionsUI.SetActive(true);
ShowModal($"{outcome}\n{player.score}-{enemy.score}");
freezeMotion = true;
+ gameover = true;
}
}
@@ -235,11 +261,19 @@ namespace Controllers
private void ShowModal(string text)
{
+ if (gameover) return;
resultOverlay.SetActive(true);
resultText.text = text;
}
- private void HideModal() => resultOverlay.SetActive(false);
+ private void HideModal()
+ {
+ if (gameover) return;
+ resultOverlay.SetActive(false);
+ }
+
+ public void Restart() => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
+ public void MainMenu() => SceneManager.LoadScene("Menu");
internal enum State
{