From f7e972ad4d1b72fcbde276347f5d517f434473de Mon Sep 17 00:00:00 2001 From: Nathan Fawcett <44716057+nFawcettPortfolio@users.noreply.github.com> Date: Sun, 2 Feb 2020 00:41:29 -0500 Subject: [PATCH] Add files via upload --- Computer.cs | 23 +++++++++++++++++++++++ FadeManager.cs | 1 + GameManager.cs | 10 +++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 Computer.cs diff --git a/Computer.cs b/Computer.cs new file mode 100644 index 0000000..fc3c150 --- /dev/null +++ b/Computer.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using TMPro; + +public class Computer : MonoBehaviour +{ + private GameManager gameManager; + public TextMeshPro iterationText; + + // Start is called before the first frame update + void Start() + { + gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent(); + } + + // Update is called once per frame + void Update() + { + if (gameManager.timeIteration>=3) + iterationText.text = gameManager.timeIteration.ToString(); + } +} diff --git a/FadeManager.cs b/FadeManager.cs index 6b95299..3f67995 100644 --- a/FadeManager.cs +++ b/FadeManager.cs @@ -22,6 +22,7 @@ public IEnumerator Fade(Color color, Image image, GameObject room) fading = true; yield return FadeIn(color, image); gameManager.Teleport(room); + if (gameManager.timeRestart) gameManager.RewindTime(); yield return new WaitForSeconds(0.25f); yield return FadeOut(image); diff --git a/GameManager.cs b/GameManager.cs index c263bb7..0216873 100644 --- a/GameManager.cs +++ b/GameManager.cs @@ -17,10 +17,10 @@ public class GameManager : MonoBehaviour public bool isPaused = false; public Image fadeImage; public FadeManager fadeManager; + public bool timeRestart = false; - - private float timeIteration; + [HideInInspector] public float timeIteration; private float timeLeft = TIMELIMIT; public TextMeshProUGUI timerText; // Start is called before the first frame update @@ -54,6 +54,7 @@ IEnumerator LoseTime() { if (timeLeft <= 0.0f) { + timeRestart = true; timerText.enabled =false; yield return timerEnded(); timerText.enabled=true; @@ -69,20 +70,19 @@ IEnumerator LoseTime() } IEnumerator timerEnded() { - timeIteration++; timeLeft = TIMELIMIT; Debug.Log("REWIND TIME\n Time iteration: "+timeIteration); fadeImage.color = Color.clear; yield return GameObject.FindGameObjectWithTag("FadeManager").GetComponent().Fade(Color.blue, fadeImage, teleportDes); - RewindTime(); } public void RewindTime() { + timeIteration++; player.SetDefault(); - + timeRestart = false; }