Beispiel #1
0
    public static void SaveScore()
    {
        int timeScore = (int)totalTime;

        totalTimeText.text = "Time: " + HighScoreController.convertSecondstoString(timeScore);

        string regionName     = MainMenuController.getRegionName();
        string difficultyName = DifficultyController.getDifficultyName();
        string scoreKey       = regionName + "_" + difficultyName + "_Score_Key";
        string timeKey        = regionName + "_" + difficultyName + "_Time_Key";
        float  highScore      = PlayerPrefs.GetFloat(scoreKey);
        int    bestTime       = PlayerPrefs.GetInt(timeKey);

        if (score > highScore || (score >= highScore && timeScore < bestTime))
        {
            PlayerPrefs.SetFloat(scoreKey, score);
            PlayerPrefs.SetInt(timeKey, timeScore);
        }
    }