| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using TMPro;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class EndGameMenu : MonoBehaviour
- {
- private SaveManager saveManager;
- GameData gameData;
- public TMP_Text textToDisplay;
- public TMP_Text score;
- // Start is called once before the first execution of Update after the MonoBehaviour is created
- void Start()
- {
- saveManager = GameObject.Find("SaveManager").GetComponent<SaveManager>();
- gameData = saveManager.LoadGame();
- if(gameData.playerScore >= 10)
- {
- textToDisplay.text = "You won! Well played!";
- score.text = "You collected every orbs (10)";
- }
- else
- {
- textToDisplay.text = "You lost! Skill issue.";
- score.text = "You collected only " + gameData.playerScore.ToString() + "/10 Orbs";
- }
-
- }
- // Update is called once per frame
- void Update()
- {
-
- }
- public void NewGame()
- {
- GameData gameData = new();
- System.Random rnd = new();
- gameData.seed = rnd.Next();
- saveManager.SaveGame(gameData);
- SceneManager.LoadScene("Game");
- }
- public void MainMenu()
- {
- GameData gameData= new();
- saveManager.SaveGame(gameData);
- SceneManager.LoadScene("Menu");
- }
- public void Quit()
- {
- Application.Quit();
- }
- }
|