Run, Hide By Tell VR Game

Run, Hide and Tell Game VRG
Run, Hide and Tell Game VRG

A scenario-based game where cadet experience different critical situations, such as active criminal attacking people in town, requiring them to choose and implement "Run or Hide by telling people" strategies.

CODE

Here's the code of Game Manager Script.


public class GameManager : MonoBehaviour
{
    public float timeRemaining = 60f;  
    public TMP_Text timerText;            
    private bool timerIsRunning = false;
    [SerializeField] GameObject GameOver;

    void Start()
    {
        Time.timeScale = 1;
        timerIsRunning = true;
    }

    void Update()
    {
        if (timerIsRunning)
        {
            if (timeRemaining > 0)
            {
                timeRemaining -= Time.deltaTime;
                UpdateTimerDisplay(timeRemaining);
            }
            else
            {
                timeRemaining = 0;
                timerIsRunning = false;
                TimerEnded();
            }
        }
    }

    void UpdateTimerDisplay(float currentTime)
    {
        currentTime += 1;
        float minutes = Mathf.FloorToInt(currentTime / 60);
        float seconds = Mathf.FloorToInt(currentTime % 60);
        timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
    }

    void TimerEnded()
    {
        Debug.Log("Timer has ended!");
        Time.timeScale = 0f;
        GameOver.SetActive(true);
    }

    public void Restart()
    {
        SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
    }
}

Made in UNITY