-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameManager.cs
62 lines (49 loc) · 1.31 KB
/
GameManager.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
private ObjectPooler objectPooler;
private float prefabHeight;
private float bldgHeight;
public List<GameObject> bldgs;
public int colour;
void Start() {
prefabHeight = 1.92f;
objectPooler = GetComponent<ObjectPooler>();
reset(true);
}
public void reset(bool start = false) {
foreach (GameObject obj in bldgs)
{
obj.SetActive(false);
}
bldgs = new List<GameObject>();
if (!start) { selectColour(); }
bldgHeight = -2.05f;
for(int i = 0; i < 8; i++) {
bldgs.Add(objectPooler.spawnFromPool(bldgHeight, colour));
bldgHeight += prefabHeight;
}
}
public void removeFirstBldg(int score)
{
bldgs.Add(objectPooler.spawnFromPool(bldgHeight, colour));
bldgHeight += prefabHeight;
}
public string getDirectionFirstBldg(int score)
{
return bldgs[score].tag.ToString();
}
public void selectColour() {
switch (colour) {
case 0:
case 1:
colour += 1;
break;
case 2:
colour = 0;
break;
}
}
}