-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.cs
More file actions
176 lines (150 loc) · 4.08 KB
/
MainMenu.cs
File metadata and controls
176 lines (150 loc) · 4.08 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class MainMenu : MonoBehaviour
{
Controls controls;
int menu;
int prevMenu;
/*
0: Main Menu
1: New Game
2: Continue
3: Level Select
4: Options
5: Leave
*/
int selection;
int maxSelect;
int moveCD;
bool noGame;
bool popUp;
bool zoomingIn;
public GameObject cursor;
float selectionTo;
float selectTo;
float fixedCursor;
public GameObject fade;
void Start()
{
controls = new Controls();
controls.UI.Enable();
controls.UI.Select.started += _ => Select();
controls.UI.Select.canceled += _ => Cancel();
maxSelect = 5;
noGame = false;
}
//Select
void Select()
{
zoomingIn = true;
switch (menu)
{
case 0:
//prevMenu = menu;
//menu = selection + 1;
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
}
}
//Back
void Cancel()
{
}
//Keyboard / Controller Navigation
void Navigation()
{
if (Mathf.Abs(controls.UI.Navigate.ReadValue<Vector2>().y) < 0.5f)
{
moveCD = 25;
}
else if (moveCD >= 25)
{
gameObject.transform.GetChild(menu + 1).GetChild(selection).GetChild(0).GetComponent<TextMeshProUGUI>().color
= new Color(1, 1, 1, 190f / 255);
if (controls.UI.Navigate.ReadValue<Vector2>().y < 0)
{
selection++;
if (noGame && menu == 0 && selection == 1) selection += 2;
}
else
{
selection--;
if (noGame && menu == 0 && selection == 2) selection -= 2;
}
selection %= maxSelect;
if (selection < 0) selection += maxSelect;
moveCD = 0;
}
}
//Mouse Hover Navigation
public void Selection(int s)
{
selection = s;
Debug.Log("test");
}
void CursorMovement()
{
if (zoomingIn)
{
cursor.transform.localPosition = new Vector3(0, selectionTo);
}
else
{
transform.GetChild(menu).transform.localScale +=
new Vector3((1f - transform.GetChild(menu).transform.localScale.x) / 15, (1f - transform.GetChild(prevMenu + 1).transform.localScale.y) / 15, 0);
cursor.transform.localPosition += new Vector3(0, (selectionTo - cursor.transform.localPosition.y) / 5);
}
}
void FixedUpdate()
{
Debug.Log(selection);
if (moveCD < 25) moveCD++;
//Selection Transitions
switch (menu)
{
case 0:
switch (selection)
{
case 0:
selectionTo = 58.3f;
break;
case 1:
selectionTo = -11.2f;
break;
case 2:
selectionTo = -75.8f;
break;
case 3:
selectionTo = -148.6f;
break;
case 4:
selectionTo = -213.4f;
break;
}
Navigation();
CursorMovement();
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
}
}