public void ShowHighScore() { //hide some objects to free space foreach (var obj in _objectsToUnshown) { obj.gameObject.SetActive(false); } //show high score table and title _highScoreTable.gameObject.SetActive(true); _highScoreTitle.gameObject.SetActive(true); //get high score (top 7) and set text string highScoreTable = ""; List <HighScorePlayer> highScores = SubmitHighScoreButton.GetHighScore(); if (highScores.Count == 0) { _highScoreTable.text = "No High Scores yet, play to submit!"; } else { for (int i = 0; i < highScores.Count; i++) { highScoreTable += i + 1 + ". " + highScores[i].GetName() + " " + highScores[i].GetScore() + "\n"; } _highScoreTable.text = highScoreTable; } GameObject.Find("ButtonSound").GetComponent <AudioSource>().Play(); }
private bool IsNewHighScore(int newScore) { bool isNewHighScore = false; List <HighScorePlayer> highScores = SubmitHighScoreButton.GetHighScore(); // new high scores if it´s the first ones if (highScores.Count < 7) { isNewHighScore = true; } foreach (HighScorePlayer player in highScores) { if (newScore > player.GetScore()) { isNewHighScore = true; } } return(isNewHighScore); }