-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuManager.cs
More file actions
154 lines (128 loc) · 3.57 KB
/
MenuManager.cs
File metadata and controls
154 lines (128 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MenuManager : MonoBehaviour {
public static MenuManager instance;
private int activeMenu = 0;
public GameObject menu;
public GameObject multiplayerMenu;
public GameObject loadingScreen;
public GameObject GUI;
public TMP_Text playText;
public TMP_Text settingsText;
public TMP_Text quitText;
public TMP_Text singleplayerText;
public TMP_Text multiplayerText;
public TMP_Text multiplayerReturnText;
public GameObject playerPrefab;
public static Vector3 spawnLocation = new(2.985f, 1f, -0.6f);
private void Awake() {
if (instance == null) instance = this;
}
public void StartGame() {
Instantiate(playerPrefab, spawnLocation, Quaternion.identity);
Destroy(Camera.main.gameObject);
Cursor.lockState = CursorLockMode.Locked;
}
public void ButtonPlay() {
menu.SetActive(false);
activeMenu = 1;
multiplayerMenu.SetActive(true);
}
public void ButtonSingleplayer() {
multiplayerMenu.SetActive(false);
EnterGame();
}
public void ButtonMultiplayer() {
}
public void ButtonReturn() {
multiplayerMenu.SetActive(false);
menu.SetActive(true);
activeMenu = 0;
}
public void EnterGame() {
Camera.main.GetComponent<Animator>().Play("Camera");
StartCoroutine(Transition());
}
IEnumerator Transition() {
yield return new WaitForSeconds(3f);
StartGame();
}
public void ButtonSettings() {
// TODO: Settings
}
public void ButtonQuit() {
Application.Quit();
// TODO: Quit Animation or smth
}
void ResetText() {
switch (activeMenu) {
case 0:
playText.text = "Play";
settingsText.text = "Settings";
quitText.text = "Quit";
playText.color = Color.white;
settingsText.color = Color.white;
quitText.color = Color.white;
break;
case 1:
singleplayerText.text = "Singleplayer";
multiplayerText.text = "Multiplayer";
multiplayerReturnText.text = "Return";
singleplayerText.color = Color.white;
multiplayerText.color = Color.white;
multiplayerReturnText.color = Color.white;
break;
default:
Debug.LogError("Invalid Menu!");
break;
}
}
public void UnHover() {
ResetText();
}
public void Hover(int hoveredButton) {
ResetText();
switch (hoveredButton) {
// Main Menu:
case 0:
playText.text = "> Play <";
playText.color = Color.yellow;
break;
case 1:
settingsText.text = "> Settings <";
settingsText.color = Color.yellow;
break;
case 2:
quitText.text = "> Quit <";
quitText.color = Color.yellow;
break;
// Multiplayer Menu
case 3:
singleplayerText.text = "> Singleplayer <";
singleplayerText.color = Color.yellow;
break;
case 4:
multiplayerText.text = "> Multiplayer <";
multiplayerText.color = Color.yellow;
break;
case 5:
multiplayerReturnText.text = "> Return <";
multiplayerReturnText.color = Color.yellow;
break;
}
}
public static bool allowTeleport = false;
void FixedUpdate() {
if (Player.shared != null)
if (Player.shared.playerCamera.transform.position.y < -10) {
if (allowTeleport) {
ItemManager.Clear();
loadingScreen.SetActive(true);
SceneManager.LoadSceneAsync(1);
allowTeleport = false;
}
}
}
}