private void InitializeSectionsData() { // load the main save MainSaveData mainSave = (MainSaveData)SerializationManager.LoadSave(SavePaths.MAIN_SAVE_FILE); if (mainSave != null) { foreach (SectionData sd in mainSave.sections) { // Create new temp section data with the sections that were manually saved. SerializationManager.Save(sd, SavePaths.SECTION_PREFIX + sd.SectionNum, SavePaths.SECTIONS_DIRECTORY); if (sd.SectionNum == PlayerData.Current.SectionNum) { // assign the current section to be section the player manually saved in SectionData.Current = sd; } } } if (SectionData.Current == null) { SectionData.Current = new SectionData(); } }
public void SaveMain(bool isSavableSection, int sectionNum) { SaveSection(isSavableSection, sectionNum); SavePlayer(sectionNum); SaveTime(); MainSaveData mainSave = new MainSaveData(); string[] filePaths = Directory.GetFiles(Application.persistentDataPath + "/" + SavePaths.SECTIONS_DIRECTORY + "/"); foreach (string path in filePaths) { string fileName = Path.GetFileNameWithoutExtension(path); SectionData section = (SectionData)SerializationManager.LoadSave(fileName, SavePaths.SECTIONS_DIRECTORY); mainSave.sections.Add(section); } if (!SerializationManager.Save(mainSave)) { Debug.Log("Main Save was unsuccesful"); } }