| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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<GameObject> 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;
- }
- }
|