// Attempts to save the current game (if successful, applies the save penalty then returns to the game) private void SaveGame() { // First restore the continuation save GameData gameData = LoadGame(true); if (gameData != null) { ResumeGame(gameData); if (GameDataIsValid(gameData, true)) { // Add the penalty for saving before saving the current game scoreController.AddSavePenalty(); // Attempt to save the current game if (persistenceController.SaveGame(PlayerPrefs.GetString("CurrentFile"))) { // Save has worked, so remove prefs no longer needed, confirm save to player and then restart game TidyLoadSavePrefs(); textDisplayController.AddTextToLog(playerMessageController.GetMessage("266Resume")); RestartGame(gameData); return; } } else { // Invalid data will have ended the game, so simply return return; } } // Save has failed, so show warning dialogue warningType = SaveLoadType.PLAYER_SAVE; OpenWarningDialogue(); }