void Start() { FirstHighScore = PlayerPrefs.GetInt(FIRST_HIGH_SCORE_KEY, 0); SecondHighScore = PlayerPrefs.GetInt(SECOND_HIGH_SCORE_KEY, 0); ThirdHighScore = PlayerPrefs.GetInt(THIRD_HIGH_SCORE_KEY, 0); NowScore = this.GetComponent <Text>(); NowScore.text = ScoreCount.ToString(); ; int ObjectCount = 0; GameObject[] Scores = new GameObject[ScoreRoot.childCount]; foreach (Transform ScoreUI in ScoreRoot) { Scores[ObjectCount] = ScoreUI.gameObject; ObjectCount++; } NowFinalScore = Scores[0].GetComponent <Text>(); FirstHighScoreText = Scores[1].GetComponent <Text>(); SecondHighScoreText = Scores[2].GetComponent <Text>(); ThirdHighScoreText = Scores[3].GetComponent <Text>(); ThirdHighScoreText.text = ThirdHighScore.ToString(); SecondHighScoreText.text = SecondHighScore.ToString(); FirstHighScoreText.text = FirstHighScore.ToString(); }
public void SetFinalScore(int p_score) { ScoreCount = p_score; if (FirstHighScore <= ScoreCount) { ThirdHighScore = SecondHighScore; SecondHighScore = FirstHighScore; FirstHighScore = ScoreCount; PlayerPrefs.SetInt(FIRST_HIGH_SCORE_KEY, FirstHighScore); PlayerPrefs.SetInt(SECOND_HIGH_SCORE_KEY, SecondHighScore); PlayerPrefs.SetInt(THIRD_HIGH_SCORE_KEY, ThirdHighScore); PlayerPrefs.Save(); ThirdHighScoreText.text = ThirdHighScore.ToString(); SecondHighScoreText.text = SecondHighScore.ToString(); FirstHighScoreText.text = FirstHighScore.ToString(); FirstHighScoreText.transform.GetChild(0).GetComponent <Image>().enabled = true; } else if (SecondHighScore <= ScoreCount) { ThirdHighScore = SecondHighScore; SecondHighScore = ScoreCount; PlayerPrefs.SetInt(SECOND_HIGH_SCORE_KEY, SecondHighScore); PlayerPrefs.SetInt(THIRD_HIGH_SCORE_KEY, ThirdHighScore); PlayerPrefs.Save(); ThirdHighScoreText.text = ThirdHighScore.ToString(); SecondHighScoreText.text = SecondHighScore.ToString(); SecondHighScoreText.transform.GetChild(0).GetComponent <Image>().enabled = true; } else if (ThirdHighScore <= ScoreCount) { ThirdHighScore = ScoreCount; PlayerPrefs.SetInt(THIRD_HIGH_SCORE_KEY, ThirdHighScore); PlayerPrefs.Save(); ThirdHighScoreText.text = ThirdHighScore.ToString(); ThirdHighScoreText.transform.GetChild(0).GetComponent <Image>().enabled = true; } }