public static void SaveGame(int slot) { if (GameManager.isInMainMenuScene) { Debug.LogWarning("Cant save in main menu scene"); return; } Debug.Log("Saving game to slot: " + slot); Debug.Log("On Save Game Event"); // let everyone know we're saving if (onSaveGame != null) { onSaveGame(SceneLoading.currentLoadedScenes); } Debug.Log("Saving Info To File"); // keep track of the scene we were in when saving // save the description info IOTools.SaveToFile(new SaveStateInfo(SceneLoading.playerScene), GetGameStatePath(slot, infoExtension)); Debug.Log("Saving Game State To File"); // save the actual game state IOTools.SaveToFile(gameSaveState.state, GetGameStatePath(slot, saveExtension)); }
static void RefreshLocations(Scene scene, string path) { string sceneName = scene.name; List <LocationTemplate> templates = GetAllLocationTemplates(scene); if (templates.Count == 0) { return; } Debug.Log("Refreshing Locations List for scene " + sceneName); List <LocationDefenition> allLocations = new List <LocationDefenition>(); AddNonAreaLocations(templates, sceneName, allLocations); AddAreaLocations(templates, sceneName, allLocations); if (allLocations.Count == 0) { return; } Dictionary <string, LocationDefenition> locationDict = new Dictionary <string, LocationDefenition>(); for (int i = 0; i < allLocations.Count; i++) { locationDict.Add(allLocations[i].name, allLocations[i]); } string directory = Locations.GetLocationsObjectDirectory(); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string filePath = Locations.GetLocationsObjectPath(); Dictionary <string, Dictionary <string, LocationDefenition> > existing; if (File.Exists(filePath)) { Debug.Log("Updating Locations File: " + filePath); existing = (Dictionary <string, Dictionary <string, LocationDefenition> >)IOTools.LoadFromFile(filePath); existing[sceneName] = locationDict; } else { Debug.Log("Creating Locations File: " + filePath); existing = new Dictionary <string, Dictionary <string, LocationDefenition> > () { { sceneName, locationDict } }; } IOTools.SaveToFile(existing, filePath); }
// call when we're done editng any settings, or when we're quittin ghte application public static void SaveSettingsOptions() { // let everyone know we're saving settings if (onSettingsSave != null) { onSettingsSave(); } IOTools.SaveToFile(settingsSaveState.state, settingsSavePath); }