-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManagerScript.cs
More file actions
58 lines (47 loc) · 1.42 KB
/
GameManagerScript.cs
File metadata and controls
58 lines (47 loc) · 1.42 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManagerScript : MonoBehaviour
{
public bool gameOver = true;
private bool paused = false;
[SerializeField] private GameObject player;
UIScript UI = null;
SpawnManagerScript SM = null;
// Start is called before the first frame update
void Start()
{
UI = GameObject.Find("Canvas").GetComponent<UIScript>();
SM = GameObject.Find("SpawnManager").GetComponent<SpawnManagerScript>();
}
// Update is called once per frame
void Update()
{
if (!gameOver && Input.GetKeyDown(KeyCode.P))
{
if (paused)
{
Time.timeScale = 1;
paused = false;
UI.HidePauseScreen();
}
else
{
// game is running
Time.timeScale = 0; // % fps, pauses game
paused = true;
UI.ShowPauseScreen();
}
}
if (gameOver && Input.GetKeyDown(KeyCode.Space))
{
// Adds the player
Instantiate(player, new Vector3(-9.2f, -2.5f, 0), Quaternion.identity);
if (UI != null)
UI.HideTitleScreen();
gameOver = false;
if (SM != null)
SM.StartSpawn();
}
}
}