Added highscores and the display of the highscore at the top of the screen

This commit is contained in:
Gregory Campbell
2020-06-09 22:20:34 -04:00
parent 89eb76f613
commit 96155b719a
6 changed files with 269 additions and 0 deletions
+9
View File
@@ -12,6 +12,7 @@ public class GameScript : MonoBehaviour
public GameObject ScoreTitle;
public Text Countdown;
public Text Score;
public Text HighScore;
public Sprite[] ObjectSprites;
private bool clicked = false;
@@ -120,6 +121,12 @@ public class GameScript : MonoBehaviour
Score.text = objectsPolished.ToString();
if(PlayerPrefs.GetInt("HighScore") < objectsPolished)
{
PlayerPrefs.SetInt("HighScore", objectsPolished);
HighScore.text = PlayerPrefs.GetInt("HighScore").ToString();
}
ScoreTitle.SetActive(true);
Object.SetActive(false);
@@ -152,6 +159,8 @@ public class GameScript : MonoBehaviour
Score.text = null;
ScoreTitle.SetActive(false);
HighScore.text = PlayerPrefs.GetInt("HighScore").ToString();
Object.transform.localScale = new Vector3(1, 1, 1);
Object.GetComponent<SpriteRenderer>().sprite = null;
Destroy(Object.GetComponent<PolygonCollider2D>());