Example #1
0
    /// <summary>
    /// Checks to see if the game was won and the current move count is less than the recorded best for the current difficulty.
    /// If so, saves it and indicates in game that it is new.
    /// </summary>
    private void SetLeastMoves()
    {
        string leastMovesKey = PlayerPrefKeys.GetLeastMovesKey(Config.config.currentDifficulty);

        if (Config.config.gameWin)
        {
            int currentMoves = Config.config.moveCounter;
            if (!PlayerPrefs.HasKey(leastMovesKey) || currentMoves < PlayerPrefs.GetInt(leastMovesKey))
            {
                PlayerPrefs.SetInt(leastMovesKey, currentMoves);
                leastMoves.color     = Color.cyan;
                leastMovesStat.color = Color.cyan;
                leastMovesStat.text  = currentMoves.ToString();
            }
            else
            {
                leastMovesStat.text = PlayerPrefs.GetInt(leastMovesKey).ToString();
            }
        }
        else if (PlayerPrefs.HasKey(leastMovesKey))
        {
            leastMovesStat.text = PlayerPrefs.GetInt(leastMovesKey).ToString();
        }
        else
        {
            leastMovesStat.text = "NULL";
        }
    }
Example #2
0
    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);
    }