-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtinctionManager.cs
More file actions
213 lines (204 loc) · 5.89 KB
/
ExtinctionManager.cs
File metadata and controls
213 lines (204 loc) · 5.89 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityStandardAssets.Characters.FirstPerson;
using System.Collections;
public class ExtinctionManager : MonoBehaviour
{
public GameObject cursor;
public float timeTaken = 0f;
public Text time;
public Text objectiveText;
public float objectiveCount = 0f;
public GameObject obj1;
public ExtinctionProgress obj1Script;
public bool obj1Cleared;
public Toggle toggle1;
public GameObject obj2;
public ExtinctionProgress obj2Script;
public bool obj2Cleared;
public Toggle toggle2;
public GameObject obj3;
public ExtinctionProgress obj3Script;
public bool obj3Cleared;
public Toggle toggle3;
public GameObject obj4;
public ExtinctionProgress obj4Script;
public bool obj4Cleared;
public Toggle toggle4;
public GameObject obj5;
public ExtinctionProgress obj5Script;
public bool obj5Cleared;
public Toggle toggle5;
public Text gameOver;
public OVRPlayerController controller;
public GameObject resumeBtn;
public GameObject quit;
public bool pause;
public Text paused;
public GameObject mainMenu;
public GameObject next;
// Use this for initialization
void Start ()
{
if (MainMenu.g1)
{
MainMenu.g1Count++;
}
if (MainMenu.g2)
{
MainMenu.g2Count++;
}
if (MainMenu.g3)
{
MainMenu.g3Count++;
}
if (MainMenu.g4)
{
MainMenu.g4Count++;
}
Time.timeScale = 1f;
InvokeRepeating("IncTime", 1f, 1f);
time.enabled = false;
Cursor.lockState = CursorLockMode.Locked;
pause = false;
obj1Cleared = false;
obj2Cleared = false;
obj3Cleared = false;
obj4Cleared = false;
obj5Cleared = false;
toggle1.isOn = false;
toggle2.isOn = false;
toggle3.isOn = false;
toggle4.isOn = false;
toggle5.isOn = false;
gameOver.enabled = false;
paused.enabled = false;
resumeBtn.SetActive(false);
quit.SetActive(false);
mainMenu.SetActive(false);
next.SetActive(false);
Time.timeScale = 1f;
}
// Update is called once per frame
void Update ()
{
if (obj1Script.objectiveCleared && !obj1Cleared)
{
objectiveCount += 1f;
obj1Cleared = true;
toggle1.isOn = true;
}
if (obj2Script.objectiveCleared && !obj2Cleared)
{
objectiveCount += 1f;
obj2Cleared = true;
toggle2.isOn = true;
}
if (obj3Script.objectiveCleared && !obj3Cleared)
{
objectiveCount += 1f;
obj3Cleared = true;
toggle3.isOn = true;
}
if (obj4Script.objectiveCleared && !obj4Cleared)
{
objectiveCount += 1f;
obj4Cleared = true;
toggle4.isOn = true;
}
if (obj5Script.objectiveCleared && !obj5Cleared)
{
objectiveCount += 1f;
obj5Cleared = true;
toggle5.isOn = true;
}
objectiveText.text = "Tasks Cleared: " + objectiveCount + "/5";
if (objectiveCount == 5)
{
cursor.SetActive(false);
controller.enabled = false;
CancelInvoke("IncTime");
Time.timeScale = 0f;
mainMenu.SetActive(true);
next.SetActive(true);
gameOver.enabled = true;
time.text = "Time Taken: " + timeTaken + "s";
time.enabled = true;
controller.enabled = false;
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}
if (!gameOver.enabled)
{
if (Input.GetKeyDown(KeyCode.Escape) && !pause)
{
pause = true;
Time.timeScale = 0f;
resumeBtn.SetActive(true);
quit.SetActive(true);
paused.enabled = true;
controller.enabled = false;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}
}
void IncTime()
{
timeTaken += 1f;
}
public void Resume()
{
pause = false;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
Time.timeScale = 1f;
controller.enabled = true;
resumeBtn.SetActive(false);
quit.SetActive(false);
paused.enabled = false;
}
public void LoadNext()
{
if (MainMenu.g1)
{
if (MainMenu.g1Count == 14)
{
SceneManager.LoadScene(0);
}
SceneManager.LoadScene(MainMenu.g1MapOrder[MainMenu.g1Count]);
}
else if (MainMenu.g2)
{
if (MainMenu.g2Count == 13)
{
SceneManager.LoadScene(0);
}
SceneManager.LoadScene(MainMenu.g2MapOrder[MainMenu.g2Count]);
}
else if (MainMenu.g3)
{
if (MainMenu.g3Count == 13)
{
SceneManager.LoadScene(0);
}
SceneManager.LoadScene(MainMenu.g3MapOrder[MainMenu.g3Count]);
}
else if (MainMenu.g4)
{
if (MainMenu.g4Count == 13)
{
SceneManager.LoadScene(0);
}
SceneManager.LoadScene(MainMenu.g1MapOrder[MainMenu.g4Count]);
}
}
public void Quit()
{
SceneManager.LoadScene(0);
}
}