-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOverScreenScript.cs
More file actions
135 lines (121 loc) · 4.66 KB
/
Copy pathGameOverScreenScript.cs
File metadata and controls
135 lines (121 loc) · 4.66 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
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
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
public class GameOverScreenScript : MonoBehaviour {
//---------------------------------------------------------------------------------
// ATTRIBUTES
//---------------------------------------------------------------------------------
[SerializeField] private GameMaster refMaster;
[SerializeField] protected GameObject panel;
[SerializeField] protected TextMeshProUGUI finalScoreText;
[SerializeField] protected TextMeshProUGUI captionText;
private bool hasShownGameOver = false;
//---------------------------------------------------------------------------------
// METHODS
//---------------------------------------------------------------------------------
/// <summary>
/// Start is called before the first frame update.
/// </summary>
void Start() {
panel.gameObject.SetActive(false);
}
/// <summary>
/// Update is called once per frame.
/// </summary>
void Update() {
if (!refMaster.inGame && !hasShownGameOver) {
hasShownGameOver = true;
showGameOverScreen(refMaster.getScore());
}
}
/// <summary>
/// Show the game over screen in the scene.
/// </summary>
/// <param name="score">The score of the player.</param>
public void showGameOverScreen(float score) {
//Initialisation:
string name;
int gameID;
panel.gameObject.SetActive(true);
//Show the score:
finalScoreText.SetText("Score: " + score.ToString());
//Get the current game:
name = SceneManager.GetActiveScene().name;
if (name == "AppleCatcher") {
gameID = 1;
} else if (name == "BrickBreaker") {
gameID = 2;
} else if (name == "UFO") {
gameID = 3;
} else {
gameID = 0;
}
//Caption:
caption(score, gameID);
}
/// <summary>
/// Select a caption to print in the game over screen.
/// </summary>
/// <param name="score">The score of the player.</param>
/// <param name="game">The game taht he was playing.</param>
protected void caption(float score, int game) {
//Initialisation:
string buffer;
string defaultString = "I don not know what to say.";
switch (game) {
default:
buffer = defaultString;
break;
case 1:
//Select the case:
if (score == 0) {
buffer = "Did you forgot the game begin ?";
} else if (score < 0) {
buffer = "Too many bad apples, you know this is not a Touhou ?";
} else if (score < 10) {
buffer = "You tried and that already a good achievement.";
} else if (score < 30) {
buffer = "I know you can do better";
} else if (score < 50) {
buffer = "Not bad.";
} else if (score > 50) {
buffer = "You are pretty good.";
} else if (score > 75) {
buffer = "You really like apples.";
} else if (score >= 90) {
buffer = "How can you have more apples than appear?";
} else {
buffer = defaultString;
}
break;
case 2:
//Select the case:
if (score == 0) {
buffer = "Did you understand the game ?";
} else if (score < 0) {
buffer = "i didn't knew it was possible...";
} else if (score < 100) {
buffer = "You start playing, but now continue.";
} else if (score < 300) {
buffer = "That's a little bit better.";
} else if (score < 500) {
buffer = "You almost complete one pattern.";
} else if (score < 850) {
buffer = "Not bad.";
} else if (score < 1000) {
buffer = "That's pretty good.";
} else if (score < 1500) {
buffer = "I think you like the game.";
} else if (score < 2000) {
buffer = "It is not to fast ?";
} else if (score > 2000) {
buffer = "Woaw, you are really good.";
} else {
buffer = defaultString;
}
break;
}
//print the caption:
captionText.SetText(buffer);
}
}