Commit ce8f955c authored by Martin Mihálik's avatar Martin Mihálik 🔥
Browse files

Timer Fix

parent 805539bf
......@@ -8,6 +8,7 @@ public class GameController : MonoBehaviour
private PauseController m_PauseController;
public bool Started { get; private set; }
public float StartTime { get; private set; }
public bool Running { get; private set; }
private void Start()
......@@ -28,6 +29,7 @@ public class GameController : MonoBehaviour
m_PauseController.Resume();
Started = true;
StartTime = Time.time;
Running = true;
}
......
......@@ -3,6 +3,8 @@ using UnityEngine.UI;
public class TimeDisplayController : MonoBehaviour
{
[SerializeField] GameController m_GameController;
private Text m_TimeDisplay;
private void Start()
......@@ -17,6 +19,13 @@ public class TimeDisplayController : MonoBehaviour
private void UpdateTimeDisplay()
{
m_TimeDisplay.text = Time.time.ToString("0.00");
if (!m_GameController.Started)
{
m_TimeDisplay.text = "0,00";
}
else
{
m_TimeDisplay.text = (Time.time - m_GameController.StartTime).ToString("0,00");
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment