using System.Collections; using System.Collections.Generic; using UnityEngine.SceneManagement; using TMPro; using UnityEditor.Overlays; using UnityEngine.UI; using UnityEngine; public class GameManager : MonoBehaviour { public TextMeshProUGUI timeRemainingText; public TextMeshProUGUI orbsCollectedText; public bool isGameActive; public GameObject GameOverScreen; public GameObject VictoryScreen; public float playerPosX; public float playerPosY; public float playerPosZ; public float playerRotX; public float playerRotY; public float playerRotZ; public int orbsCollected = 0; public float seed; public List orbs; public int timeRemaining = 20; public int settings; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } public void StartGame(int difficulty) { isGameActive = true; } public void RestartGame() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } public void GameOver() { GameOverScreen.SetActive(true); isGameActive = false; } public void Victory() { VictoryScreen.SetActive(true); isGameActive = false; } public void SaveGame() { SaveSystem.SaveGame(this); } public void LoadGame() { GameData data = SaveSystem.LoadGame(); playerPosX = data.playerPosX; playerPosY = data.playerPosY; playerPosZ = data.playerPosZ; playerRotX = data.playerRotX; playerRotY = data.playerRotY; playerRotZ = data.playerRotZ; orbsCollected = data.orbsCollected; seed = data.seed; for (int i = 0; i < orbs.Count; i++) { } isGameActive = data.isGameActive; timeRemaining = data.timeRemaining; settings = data.settings; } // Update is called once per frame void Update() { UpdateTimeRemaining(); //Victory if (orbsCollected == orbs.Count) { Victory(); } //Game Over if (timeRemaining == 0) { GameOver(); } if(Input.GetKeyDown(KeyCode.F5)) { SaveGame(); } if(Input.GetKeyDown(KeyCode.F9)) { LoadGame(); } } public void UpdateTimeRemaining() { timeRemaining--; timeRemainingText.text = "RemainingTime: " + timeRemaining * Time.deltaTime; } public void UpdateCollectedOrbs() { orbsCollected++; orbsCollectedText.text = "Collected Orbs: " + orbsCollected; } }