-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoreBoard.cs
42 lines (35 loc) · 915 Bytes
/
ScoreBoard.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreBoard : MonoBehaviour {
private int score;
private int highScore;
public Text scoreText;
public Text highScoreText;
void Awake() {
score = 0;
highScore = PrefsManager.GetHighScore ();
scoreText = GetScoreTextObj ();
highScoreText = GetHighScoreTextObj ();
SetText ();
}
public Text GetScoreTextObj() {
return GameObject.Find ("ScoreText").GetComponent<Text>();
}
public Text GetHighScoreTextObj() {
return GameObject.Find ("HighScoreText").GetComponent<Text>();
}
public void SetText() {
scoreText.text = "Score: " + score.ToString ();
highScoreText.text = "High Score: " + highScore.ToString ();
}
public void Increment() {
score += 325;
if (score > highScore) {
highScore = score;
PrefsManager.SetHighScore (highScore);
}
SetText ();
}
}