public void setToSociety(Society soc) { state = uiState.SOCIETY; uiMainMenu.gameObject.SetActive(false); uiLeftPrimary.gameObject.SetActive(true); uiScrollables.gameObject.SetActive(true); uiMidTop.gameObject.SetActive(true); uiVoting.gameObject.SetActive(false); uIMidLower.gameObject.SetActive(false); hexSelector.SetActive(false); uiTopLight.gameObject.SetActive(true); uiScrollables.viewSocButtonText.text = "View World"; GraphicalSociety.purge(); GraphicalMap.purge(); GraphicalSociety.setup(soc); uiLeftPrimary.maskTitle.text = "Neighbor Liking View"; GraphicalSociety.refreshNeighbor(GraphicalSociety.focus); checkData(); }
public void save(string filename) { World world = this; world.ui.setToMainMenu(); GraphicalMap.purge(); GraphicalSociety.purge(); world.map.world = null;
public void save(string filename) { try { World world = this; // world.ui.setToMainMenu(); GraphicalMap.purge(); GraphicalSociety.purge(); world.map.world = null; //foreach (SocialGroup sg in map.socialGroups) //{ // if (sg is Society) // { // Society soc = (Society)sg; // soc.voteSession = null; // } //} fsSerializer _serializer = new fsSerializer(); fsData data; _serializer.TrySerialize(typeof(Map), map, out data).AssertSuccessWithoutWarnings(); // emit the data via JSON string saveString = fsJsonPrinter.CompressedJson(data); World.Log("Save exit point"); if (File.Exists(filename)) { World.Log("Overwriting old save: " + filename); File.Delete(filename); } File.WriteAllLines(filename, new string[] { saveString }); world.map.world = world; staticMap = map; world.prefabStore.popMsg("Game saved as: " + filename); //// step 1: parse the JSON data //fsData data = fsJsonParser.Parse(serializedState); //// step 2: deserialize the data //object deserialized = null; //_serializer.TryDeserialize(data, type, ref deserialized).AssertSuccessWithoutWarnings(); }catch (Exception e) { World.log(e.Message); World.log(e.StackTrace); prefabStore.popMsg("Failure to save"); prefabStore.popMsg("Exception: " + e.StackTrace); } }
/* * public void bViewSociety() * { * if (GraphicalMap.selectedHex == null) { return; } * if (GraphicalMap.selectedHex.owner == null) { return; } * if (GraphicalMap.selectedHex.owner is Society == false) { return; } * if (GraphicalMap.selectedHex.settlement != null) * { * if (GraphicalMap.selectedHex.settlement is Set_City) * { * Set_City city = (Set_City)GraphicalMap.selectedHex.settlement; * if (city.lordSlot != null) * { * setToSociety(city.lordSlot.society, city.lordSlot); * return; * } * } * } * setToSociety((Society)GraphicalMap.selectedHex.owner); * } */ /* * public void setToSociety(Society soc) * { * state = uiState.SOCIETY; * uiWorldRight.gameObject.SetActive(false); * uiHex.gameObject.SetActive(false); * uiMainMenu.gameObject.SetActive(false); * uiSociety.gameObject.SetActive(true); * uiCommon.gameObject.SetActive(true); * uiCity.gameObject.SetActive(false); * GraphicalMap.purge(); * * GraphicalSociety.centreOn(soc.command.top); * uiSociety.setTo(soc.command.top.person); * } * public void setToSociety(Society soc, Slot slot) * { * state = uiState.SOCIETY; * uiWorldRight.gameObject.SetActive(false); * uiHex.gameObject.SetActive(false); * uiMainMenu.gameObject.SetActive(false); * uiSociety.gameObject.SetActive(true); * uiCommon.gameObject.SetActive(true); * uiCity.gameObject.SetActive(false); * GraphicalMap.purge(); * * GraphicalSociety.centreOn(slot); * uiSociety.setTo(slot.person); * } */ public void setToBackground() { state = uiState.BACKGROUND; uiMainMenu.gameObject.SetActive(false); uiLeftPrimary.gameObject.SetActive(false); uiScrollables.gameObject.SetActive(false); uiMidTop.gameObject.SetActive(false); hexSelector.SetActive(false); GraphicalMap.purge(); GraphicalSociety.purge(); }
public void load(string filename) { try { if (map != null) { GraphicalMap.purge(); GraphicalSociety.purge(); map.world = null; map = null; } filename = saveFolder + filename; string fullFile = File.ReadAllText(filename); //string serializedState = fullFile.Substring(fullFile.IndexOf("\n"), fullFile.Length); int startIndex = fullFile.IndexOf(saveHeader) + saveHeader.Length; int endIndex = fullFile.Length - startIndex; string serializedState = fullFile.Substring(startIndex, endIndex); fsSerializer _serializer = new fsSerializer(); fsData data = fsJsonParser.Parse(serializedState); World.Log("Data parsed"); object deserialized = null; _serializer.TryDeserialize(data, typeof(Map), ref deserialized).AssertSuccessWithoutWarnings(); World.saveLog.takeLine("Finished deserial"); map = (Map)deserialized; map.world = this; staticMap = map; World.self.displayMessages = true; GraphicalMap.map = map; //ui.setToMainMenu(); //GraphicalMap.checkLoaded(); //GraphicalMap.checkData(); //graphicalMap.loadArea(0, 0); map.decompressFromSave(); prefabStore.popMsg("Loaded file: " + filename, true); World.Log("reached end of loading code"); // prefabStore.popMsg("Load may well have succeeded."); } catch (FileLoadException e) { Debug.Log(e); World.log(e.StackTrace); prefabStore.popMsg("Exception: " + e.StackTrace, true); } catch (Exception e2) { Debug.Log(e2); World.log(e2.StackTrace); prefabStore.popMsg("Exception: " + e2.StackTrace, true); } }
public void setToWorld() { state = uiState.WORLD; uiMainMenu.gameObject.SetActive(false); uiLeftPrimary.gameObject.SetActive(true); uiScrollables.gameObject.SetActive(true); uiMidTop.gameObject.SetActive(true); hexSelector.SetActive(true); uiScrollables.viewSocButtonText.text = "View Society"; GraphicalSociety.purge(); }
public void setToMainMenu() { state = uiState.MAIN_MENU; uiMainMenu.gameObject.SetActive(true); uiLeftPrimary.gameObject.SetActive(false); uiScrollables.gameObject.SetActive(false); uiMidTop.gameObject.SetActive(false); hexSelector.SetActive(false); if (World.staticMap != null) { GraphicalSociety.purge(); GraphicalMap.purge(); } }
public void load(string filename) { try { if (map != null) { GraphicalMap.purge(); GraphicalSociety.purge(); map.world = null; map = null; } string serializedState = File.ReadAllText(filename); fsSerializer _serializer = new fsSerializer(); fsData data = fsJsonParser.Parse(serializedState); World.Log("Data parsed"); object deserialized = null; _serializer.TryDeserialize(data, typeof(Map), ref deserialized).AssertSuccessWithoutWarnings(); World.saveLog.takeLine("Finished deserial"); map = (Map)deserialized; map.world = this; staticMap = map; GraphicalMap.map = map; //ui.setToMainMenu(); //GraphicalMap.checkLoaded(); //GraphicalMap.checkData(); //graphicalMap.loadArea(0, 0); prefabStore.popMsg("Loaded file: " + filename); World.Log("reached end of loading code"); // prefabStore.popMsg("Load may well have succeeded."); } catch (FileLoadException e) { Debug.Log(e); World.log(e.StackTrace); prefabStore.popMsg("Exception: " + e.StackTrace); } catch (Exception e2) { Debug.Log(e2); World.log(e2.StackTrace); prefabStore.popMsg("Exception: " + e2.StackTrace); } }
public void setToVoting() { state = uiState.VOTING; uiMainMenu.gameObject.SetActive(false); uiLeftPrimary.gameObject.SetActive(false); uiScrollables.gameObject.SetActive(false); uiMidTop.gameObject.SetActive(false); uiVoting.gameObject.SetActive(true); uIMidLower.gameObject.SetActive(false); hexSelector.SetActive(false); uiTopLight.gameObject.SetActive(false); if (World.staticMap != null) { GraphicalSociety.purge(); GraphicalMap.purge(); } }
public void save(string filename, bool popMsg = true) { Map rescueMap = World.staticMap; if (checkSaveFolder() == false) { prefabStore.popMsg("Unable to locate directory " + saveFolder + ". Saving cannot proceed without folder access. Aborting save.", true); return; } if (!hasWritePermission(saveFolder)) { prefabStore.popMsg("Unable to write to directory " + saveFolder + ". Saving cannot proceed without folder access. Aborting save.", true); World.autosavePeriod = -1; return; } try { World world = this; // world.ui.setToMainMenu(); GraphicalMap.purge(); GraphicalSociety.purge(); map.compressForSave(); world.map.world = null; //foreach (SocialGroup sg in map.socialGroups) //{ // if (sg is Society) // { // Society soc = (Society)sg; // soc.voteSession = null; // } //} fsSerializer _serializer = new fsSerializer(); fsData data; _serializer.TrySerialize(typeof(Map), map, out data).AssertSuccessWithoutWarnings(); // emit the data via JSON string saveString = fsJsonPrinter.CompressedJson(data); World.Log("Save data exit point"); string catSaveString = "Version;" + World.versionNumber + ";" + World.subversionNumber; catSaveString += saveHeader; catSaveString += saveString; if (File.Exists(filename)) { World.Log("Overwriting old save: " + filename); File.Delete(filename); } File.WriteAllLines(filename, new string[] { catSaveString });//Do it all on one line, to avoid faff wrt line endings world.map.world = world; staticMap = map; map.decompressFromSave(); if (popMsg) { world.prefabStore.popMsg("Game saved as: " + filename, true); } //// step 1: parse the JSON data //fsData data = fsJsonParser.Parse(serializedState); //// step 2: deserialize the data //object deserialized = null; //_serializer.TryDeserialize(data, type, ref deserialized).AssertSuccessWithoutWarnings(); } catch (Exception e) { World.log(e.Message); World.log(e.StackTrace); prefabStore.popMsg("Failure to save", true); prefabStore.popMsg("Exception: " + e.StackTrace, true); map = rescueMap; map.world = this; staticMap = map; } }