public bool LoadFromSave() { bool r = false; if (File.Exists(Application.persistentDataPath + saveName)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream f = File.OpenRead(Application.persistentDataPath + saveName); try { dataStore = formatter.Deserialize(f) as GameDataManager_DataStore; r = true; f.Close(); } catch (System.Exception) { f.Close(); EraseSave(); r = false; } } if (dataStore == null) { RegenerateDataStore(); } else { dataStore.sovereignAdventurer.SanityCheck(); for (int i = 0; i < dataStore.housingLevel; i++) { dataStore.houseAdventurers[i].SanityCheck(); } } return(r); }
public void RegenerateDataStore() { dataStore = new GameDataManager_DataStore(); RecalculateResourceMaximums(); DetermineNextPromoteUnlock(); for (int i = 0; i < dataStore.housingLevel; i++) { dataStore.houseAdventurers[i].Reroll(AdventurerClass.Warrior, AdventurerSpecies.Human, dataStore.housingUnitUpgrades[i], Adventurer.GetRandomStatPoint()); } dataStore.sovereignMugshot = (AdventurerMugshot)Random.Range((int)AdventurerMugshot.Sovereign0, (int)AdventurerMugshot.Sovereign7 + 1); dataStore.sovereignAdventurer.Reroll(AdventurerClass.Sovereign, AdventurerSpecies.Human, false, new int[] { 0, 0, 0, 0 }); saveExisted = false; }