-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreManager.cs
More file actions
33 lines (28 loc) · 869 Bytes
/
ScoreManager.cs
File metadata and controls
33 lines (28 loc) · 869 Bytes
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
using UnityEngine;
using System.Collections;
public class ScoreManager : MonoBehaviour {
public int score = 0;
public bool hasLost = false;
public Transform explosionPrefab;
// Update is called once per frame
void Update () {
if (score <= -10)
{
//hasLost = true;
}
}
void OnGUI()
{
GUI.color = Color.black;
GUI.Label(new Rect(0, 0, 100, 50), "Score: " + score);
if (hasLost)
{
GUI.color = Color.black;
GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 25, 100, 50), "GAME OVER!");
if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 25 + 55, 100, 50), "Restart!"))
{
Application.LoadLevel(Application.loadedLevel);
}
}
}
}