public void ClearRecordsConfirmationButton(bool confirm) { if (confirm) { // since ResultsScript.cs detects and auto fills the very first records this is how it must be done foreach (string difficulty in Config.config.difficulties) { PlayerPrefs.DeleteKey(PlayerPrefKeys.GetHighScoreKey(difficulty)); PlayerPrefs.DeleteKey(PlayerPrefKeys.GetLeastMovesKey(difficulty)); } } confirmButton.SetActive(false); }
/// <summary> /// Checks to see if the current score is better than the recorded best for the current difficulty. /// If so, saves it and indicates in game that it is new. /// </summary> private void SetHighScore() { string highScoreKey = PlayerPrefKeys.GetHighScoreKey(Config.config.currentDifficulty); int currentScore = Config.config.score; if (!PlayerPrefs.HasKey(highScoreKey) || currentScore > PlayerPrefs.GetInt(highScoreKey)) { PlayerPrefs.SetInt(highScoreKey, currentScore); highScore.color = Color.cyan; highScoreStat.color = Color.cyan; highScoreStat.text = currentScore.ToString(); } else { highScoreStat.text = PlayerPrefs.GetInt(highScoreKey).ToString(); } }