示例#1
0
    public static void SaveGame()
    {
        PlayerPrefs.SetInt(Literals.Saves.First_SAVE, 1);

        if (GameInstructions.GAME_MODE == Literals.GAME_MODES.NORNAL_GAME_MODE)
        {
            if (scoreManager.Score >= PlayerPrefs.GetInt(Literals.Saves.BEST_SCORE_NORMAL))
            {
                PlayerPrefs.SetInt(Literals.Saves.BEST_SCORE_NORMAL, scoreManager.Score);
            }

            PlayerPrefs.SetString(Literals.Saves.BEST_TIME_NORMAL, lastTimer.CompareTime(lastTimer.GetTime(), PlayerPrefs.GetString(Literals.Saves.BEST_TIME_NORMAL)));

            if (KillStreakManager.KillStreak >= PlayerPrefs.GetInt(Literals.Saves.LONGEST_KILLSTREAK_NORMAL))
            {
                PlayerPrefs.SetInt(Literals.Saves.LONGEST_KILLSTREAK_NORMAL, KillStreakManager.KillStreak);
            }

            if (EnemyHealth.enemiesKilledCounter >= PlayerPrefs.GetInt(Literals.Saves.HIGHEST_ZOMBIES_KILLED_NORMAL))
            {
                PlayerPrefs.SetInt(Literals.Saves.HIGHEST_ZOMBIES_KILLED_NORMAL, EnemyHealth.enemiesKilledCounter);
            }

            if (scoreManager.Level >= PlayerPrefs.GetInt(Literals.Saves.TOP_LEVEL))
            {
                PlayerPrefs.SetInt(Literals.Saves.TOP_LEVEL, scoreManager.Level);
            }
        }
        else
        {
            if (scoreManager.Score >= PlayerPrefs.GetInt(Literals.Saves.BEST_SCORE_HEAT))
            {
                PlayerPrefs.SetInt(Literals.Saves.BEST_SCORE_HEAT, scoreManager.Score);
            }

            PlayerPrefs.SetString(Literals.Saves.BEST_TIME_HEAT, lastTimer.CompareTime(lastTimer.GetTime(), PlayerPrefs.GetString(Literals.Saves.BEST_TIME_HEAT)));

            if (KillStreakManager.KillStreak >= PlayerPrefs.GetInt(Literals.Saves.LONGEST_KILLSTREAK))
            {
                PlayerPrefs.SetInt(Literals.Saves.LONGEST_KILLSTREAK, KillStreakManager.KillStreak);
            }

            if (EnemyHealth.enemiesKilledCounter >= PlayerPrefs.GetInt(Literals.Saves.HIGHEST_ZOMBIES_KILLED))
            {
                PlayerPrefs.SetInt(Literals.Saves.HIGHEST_ZOMBIES_KILLED, EnemyHealth.enemiesKilledCounter);
            }

            if (scoreManager.Heat >= PlayerPrefs.GetInt(Literals.Saves.TOP_HEAT))
            {
                PlayerPrefs.SetInt(Literals.Saves.TOP_HEAT, scoreManager.Heat);
            }
        }

        PlayerPrefs.Save();
    }