49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class MainMenuManager : MonoBehaviour {
|
|
public enum MenuMode {
|
|
MainMenu,
|
|
PauseMenu,
|
|
}
|
|
|
|
[SerializeField] [Required]
|
|
Text titleLable;
|
|
[SerializeField] string[] titleOptions;
|
|
[SerializeField] [Required]
|
|
Button startButton;
|
|
MenuMode mode;
|
|
|
|
void Awake() => mode = MenuMode.MainMenu;
|
|
|
|
void Start() {
|
|
if (titleOptions.Length == 0) {
|
|
Debug.LogWarning("No titles listed.");
|
|
return;
|
|
}
|
|
|
|
if (PlayerPrefs.HasKey(GameTimer.HIGH_SCORE_KEY) && PlayerPrefs.GetFloat(GameTimer.HIGH_SCORE_KEY) > 0f)
|
|
titleLable.text = titleOptions[Random.Range(0, titleOptions.Length)];
|
|
else
|
|
titleLable.text = titleOptions[0];
|
|
}
|
|
|
|
public void SetMenuMode(MenuMode mode) {
|
|
this.mode = mode;
|
|
|
|
bool mainMenu = mode == MenuMode.MainMenu;
|
|
startButton.gameObject.SetActive(mainMenu);
|
|
titleLable.gameObject.SetActive(mainMenu);
|
|
}
|
|
|
|
public void ResetMenuState() {
|
|
//TODO Reset selected button
|
|
}
|
|
|
|
public void GoToScene(int sceneNb) => SceneManager.LoadScene(sceneNb);
|
|
|
|
public void QuitGame() => Application.Quit(0);
|
|
}
|