Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Computer.cs
Original file line number Diff line number Diff line change
@@ -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<GameManager>();
}

// Update is called once per frame
void Update()
{
if (gameManager.timeIteration>=3)
iterationText.text = gameManager.timeIteration.ToString();
}
}
1 change: 1 addition & 0 deletions FadeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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);
Expand Down
13 changes: 7 additions & 6 deletions GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public class GameManager : MonoBehaviour
private Player player;
public GameObject teleportDes;
public bool isPaused = false;
public Image fadeImage;
public FadeManager fadeManager;
public bool timeRestart = false;
private Image fadeImage;
private FadeManager fadeManager;



private float timeIteration;
[HideInInspector] public float timeIteration;
private float timeLeft = TIMELIMIT;
public TextMeshProUGUI timerText;
// Start is called before the first frame update
Expand Down Expand Up @@ -57,6 +58,7 @@ IEnumerator LoseTime()
{
if (timeLeft <= 0.0f)
{
timeRestart = true;
timerText.enabled =false;
yield return timerEnded();
timerText.enabled=true;
Expand All @@ -72,20 +74,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<FadeManager>().Fade(Color.blue, fadeImage, teleportDes);
RewindTime();

}

public void RewindTime()
{
timeIteration++;
player.SetDefault();

timeRestart = false;


}
Expand Down