using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using TMPro; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class GameManagerScript : MonoBehaviour { public GameObject gameOverUI; // Reference to the Game Over UI public GameObject mainMenuUI; // Reference to the Main Menu UI public GameObject controlsUI; // Reference to the Controls UI public PlayerHealth playerHealth; // Reference to the PlayerHealth component void Start() { // Find and assign the PlayerHealth component from the player GameObject playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent(); } public void GameOver() { // Activate the Game Over UI gameOverUI.SetActive(true); Time.timeScale = 0f; // Pause the game Debug.Log("Game Over"); } public void Restart() { // Deactivate the Game Over UI gameOverUI.SetActive(false); Time.timeScale = 1f; // Resume the game // Reload the current scene to restart the game SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } public void MainMenu() { Time.timeScale = 1f; // Resume the game // Load the Main Menu scene SceneManager.LoadScene("MainMenu"); } public void Quit() { // Log message and quit the game Debug.Log("Quit game"); Application.Quit(); } public void PlayGame() { PlayerPrefs.SetInt("CoinCount", 0); // Reset the coin count PlayerPrefs.SetInt("DeathCount", 0); // Reset the death count // Load the Level_1 scene to start the game SceneManager.LoadScene("Level_1"); } public void ShowControls() { // Hide the main menu and show the controls UI mainMenuUI.SetActive(false); controlsUI.SetActive(true); } public void BackToMainMenu() { // Show the main menu and hide the controls UI mainMenuUI.SetActive(true); controlsUI.SetActive(false); } }