-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelManager.cs
151 lines (117 loc) · 4.1 KB
/
LevelManager.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
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
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelManager : MonoBehaviour
{
//public float RateOfEnemySpawn;
//float CurrentRateOfEnemySpawn;
//float CurrentRateOfDummySpawn;
//public float RateOfDummySpawn;
//public bool CanSpawn;
//public int RemainingEnemies;
//public float The3Secs;
//public TextMeshProUGUI The3SecsText;
public bool The3SecsOver = false;
public GameObject The3secsBoard;
public float The3SecsSpeedMultiplier;
public GameObject WinBoard;
public GameObject LooseBoard;
public GameObject IntactPlayer;
public GameObject Enemy;
public GameObject GuardGroup;
public bool Initialised = false;
public bool LevelCompleted = false;
public bool preparingForUI = false;
public float TimBtwMatchEndAndUI;
//public float DelayToSpawnObjects;
//public TextMeshProUGUI DashBEnems;
public bool LevelEnded;
// Start is called before the first frame update
void Start()
{
//The3Secs = 3;
//RemainingEnemies = 1;
//CurrentRateOfEnemySpawn = 0;
//CurrentRateOfDummySpawn = 0;
//CanSpawn = true;
//GameObject.FindGameObjectsWithTag("Enemies");
}
// Update is called once per frame
void Update()
{
//if(!Initialised)
//{
//Initialise();
//}
if (preparingForUI)
{
TimBtwMatchEndAndUI -= Time.deltaTime;
}
if(TimBtwMatchEndAndUI <= 0)
{
preparingForUI = false;
if(LevelCompleted)
{
if(!WinBoard.activeSelf)
{
FindObjectOfType<AudioManager>().Play("Win");
}
WinBoard.SetActive(true);
}
else
{
if (!LooseBoard.activeSelf)
{
FindObjectOfType<AudioManager>().Play("Lose");
}
//print("Lose");
LooseBoard.SetActive(true);
}
}
}
public void WinThisLevel()
{
if (LevelEnded == false)
{
LevelEnded = true;
LevelCompleted = true;
//GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMoment>().CanMove = false;
FindObjectOfType<MySceneManager>().IJustCompletedALevel(SceneManager.GetActiveScene().buildIndex - 5);
WinBoard.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = "LEVEL "+ (SceneManager.GetActiveScene().buildIndex - 5).ToString();
//CanSpawn = false;
preparingForUI = true;
}
}
public void LoseThisLevel(string HowWeLost)
{
if (LevelEnded == false)
{
LevelEnded = true;
LevelCompleted = false;
preparingForUI = true;
LooseBoard.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = HowWeLost;
//GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMoment>().CanMove = false;
}
}
public void Initialise()
{
Instantiate(IntactPlayer, GameObject.FindGameObjectWithTag("PlayerSpawnPoint").transform.position, Quaternion.identity);
GameObject[] GuardPlaces = GameObject.FindGameObjectsWithTag("GuardSpawnPoint");
if(GuardPlaces.Length > 0)
{
foreach (GameObject G in GuardPlaces)
{
Instantiate(GuardGroup, G.transform.position, G.transform.rotation);
}
}
GameObject[] EnemyPlaces = GameObject.FindGameObjectsWithTag("EnemySpawnPoint");
foreach (GameObject E in EnemyPlaces)
{
Instantiate(Enemy, E.transform.position, E.transform.rotation);
}
Initialised = true;
}
}