static public void DeleteSave() { if (File.Exists(filePath)) { File.Delete(filePath); saveFile = new SaveFile(); Debug.Log("SaveGameManager:DeleteSave() – Successfully deleted save file."); } else { Debug.LogWarning("SaveGameManager:DeleteSave() – Unable to find and delete save file!" + " This is absolutely fine if you've never saved or have just deleted the file."); } // Lock the file to prevent any saving LOCK = true; // Select the basic ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, 0); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, 0); // Clear the Steps & Achievements AchievementManager.ClearStepsAndAchievements(); // Unlock the file LOCK = false; }
static public void Load() { if (File.Exists(filePath)) { string dataAsJson = File.ReadAllText(filePath); #if DEBUG_VerboseConsoleLogging Debug.Log("SaveGameManager:Load() – File text is:\n" + dataAsJson); #endif try { saveFile = JsonUtility.FromJson <SaveFile>(dataAsJson); } catch { Debug.LogWarning("SaveGameManager:Load() – SaveFile was malformed.\n" + dataAsJson); return; } #if DEBUG_VerboseConsoleLogging Debug.Log("SaveGameManager:Load() – Successfully loaded save file."); #endif LOCK = true; // Load the Achievements AchievementManager.LoadDataFromSaveFile(saveFile); // Load the selected ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, saveFile.selectedBody); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, saveFile.selectedTurret); LOCK = false; } else { #if DEBUG_VerboseConsoleLogging Debug.LogWarning("SaveGameManager:Load() – Unable to find save file. " + "This is totally fine if you've never gotten a game over " + "or completed an Achievement, which is when the game is saved."); #endif LOCK = true; // Init Achievements AchievementManager.ClearStepsAndAchievements(); // Init the selected ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, 0); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, 0); LOCK = false; } }