StartMenu.cs (1238B)
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using UnityEngine.SceneManagement; 5 using UnityEngine.UI; 6 using TMPro; 7 8 9 10 public class StartMenu : MonoBehaviour 11 { 12 public GameObject settings; 13 public GameObject healthAmount; 14 15 public void startGame() 16 { 17 if (PlayerPrefs.HasKey("health")) 18 PublicStatHandler.GetInstance().health = PlayerPrefs.GetInt("health"); 19 SceneManager.LoadScene(1); 20 } 21 22 public void quitGame() 23 { 24 Application.Quit(); 25 } 26 27 public void changeHealth(int amount) 28 { 29 PublicStatHandler.GetInstance().health += amount; 30 if (PublicStatHandler.GetInstance().health > 6) 31 PublicStatHandler.GetInstance().health = 6; 32 33 else if (PublicStatHandler.GetInstance().health < 1) 34 PublicStatHandler.GetInstance().health = 1; 35 36 PlayerPrefs.SetInt("health", PublicStatHandler.GetInstance().health); 37 updateHealthAmount(); 38 } 39 40 public void showSettings(bool on) 41 { 42 settings.SetActive(on); 43 } 44 45 public void updateHealthAmount() 46 { 47 healthAmount.GetComponent<TextMeshProUGUI>().text = PublicStatHandler.GetInstance().health+""; 48 } 49 }