-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.cs
More file actions
76 lines (62 loc) · 1.86 KB
/
GameManager.cs
File metadata and controls
76 lines (62 loc) · 1.86 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
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public float GameTime = 60;
public float T;
public GameObject Player;
public GameObject initscore;
public KeepScore readval;
public Text Score;
public int score;
private float delay = 4f;
bool ended = false;
public void EndGame()
{
GameTime -= Time.deltaTime;
T = GameTime;
readval = Player.GetComponent<KeepScore>();
score = readval.Points;
Score.text = GameTime.ToString("0");
if (GameTime < 0 && ended == false)
{
if (PlayerPrefs.GetInt("HighScore") < score)
{
PlayerPrefs.SetInt("HighScore", score);
}
Score.text = "GAME OVER: Score " + score.ToString();
ended = true;
FindObjectOfType<PlayerBehaviour>().enabled = false;
FindObjectOfType<MobileMovement>().enabled = false;
FindObjectOfType<CoinMovement>().enabled = false;
FindObjectOfType<KeepScore>().enabled = false;
FindObjectOfType<TextDisplay>().enabled = false;
FindObjectOfType<TextDisplay>().enabled = false;
initscore.GetComponent<Text>().enabled = false;
FindObjectOfType<CameraMovement>().enabled = false;
Invoke("Pause", delay);
}
}
public void Restart()
{
SceneManager.LoadScene(0);
}
public void Commence()
{
SceneManager.LoadScene(1);
}
public void Resume()
{
SceneManager.LoadScene(1);
}
public void Pause()
{
SceneManager.LoadScene(2);
}
public void Credits()
{
SceneManager.LoadScene(3);
}
}