public void HardReset() { reset(); GuildManager.resetAllUpgrades(); StatisticsTracker.HardReset(); FieldInfo[] fields = typeof(Industries).GetFields(); foreach (FieldInfo field in fields) { Industry ind = (Industry)field.GetValue(null); ind.startingVendors = 0; ind.apprentices = 0; ind.SetRawVendors(0); } maxVendors = 3; renown = totalRenown = 0; money = 20; maxApprentices = 0; currentApprentices = 0; journeymen = 0; totalQuestsCompletedRenown = 0; questsCompletedRenown = 0; skillPoints = 0; totalSkillPoints = 0; researchTime = 0; StatisticsTracker.lifetimeMoney.setValue(money); builtItems = new List <Industry>(); resetLevel = 1; upgrades.Clear(); SetDefaultUpgrades(); currentGuildmaster = new Master(); miscInventory.Clear(); unidentifiedRelics.Clear(); AchievementsManager.setupUI(); }
public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("SaveVersion", 24); info.AddValue("money", money.ToString()); info.AddValue("moneyFloor", moneyFloor.ToString()); //info.AddValue("lifetimeMoney", StatisticsTracker.lifetimeMoney.ToString()); info.AddValue("renown", renown.ToString()); info.AddValue("totalRenown", totalRenown.ToString()); info.AddValue("maxVendors", maxVendors); info.AddValue("currentVendors", currentVendors); info.AddValue("maxApprentices", maxApprentices); info.AddValue("journeymen", journeymen); info.AddValue("currentApprentices", currentApprentices); info.AddValue("totalQuestsCompleted", totalQuestsCompletedRenown); info.AddValue("questsCompleted", questsCompletedRenown); info.AddValue("skillPoints", skillPoints.ToString()); info.AddValue("totalSkillPoints", totalSkillPoints.ToString()); info.AddValue("resetLevel", resetLevel); info.AddValue("researchTime", researchTime); info.AddValue("miscInventorySize", miscInventory.Count); for (int i = 0; i < miscInventory.Count; i++) { info.AddValue("miscInventory_" + i, miscInventory[i], typeof(ItemStack)); } info.AddValue("unidentifiedRelicsSize", unidentifiedRelics.Count); for (int i = 0; i < unidentifiedRelics.Count; i++) { info.AddValue("unidentifiedRelics_" + i, unidentifiedRelics[i], typeof(ItemStack)); } info.AddValue("builtItemsSize", builtItems.Count); for (int i = 0; i < builtItems.Count; i++) { info.AddValue("buildItemID_" + i, builtItems[i].saveName); info.AddValue("builtItems_" + i, builtItems[i], typeof(Industry)); } FieldInfo[] fields = typeof(Industries).GetFields(); info.AddValue("allIndustries", fields.Length); for (int i = 0; i < fields.Length; i++) { FieldInfo field = fields[i]; Industry item = (Industry)field.GetValue(null); info.AddValue("allIndustriesID_" + i, item.saveName); info.AddValue("allIndustriesX_" + i, item.getGridPos().x); info.AddValue("allIndustriesY_" + i, item.getGridPos().y); info.AddValue("allIndustriesAB_" + i, item.doAutobuild); info.AddValue("allIndustriesABLvl_" + i, item.autoBuildLevel); info.AddValue("allIndustriesABMag_" + i, item.autoBuildMagnitude); info.AddValue("allIndustriesABVend_" + i, item.startingVendors); } //Debug.Log("Saving " + QuestManager.activeQuests.Count + " active quests"); info.AddValue("activeQuestsSize", QuestManager.activeQuests.Count); for (int i = 0; i < QuestManager.activeQuests.Count; i++) { info.AddValue("activeQuests_" + i, QuestManager.activeQuests[i], typeof(Quest)); } //Debug.Log("Saving " + QuestManager.availableQuests.Count + " available quests"); info.AddValue("availableQuestsSize", QuestManager.availableQuests.Count); for (int i = 0; i < QuestManager.availableQuests.Count; i++) { info.AddValue("availableQuests_" + i, QuestManager.availableQuests[i], typeof(Quest)); } info.AddValue("availableRelicsSize", QuestManager.availableRelics.Count); for (int i = 0; i < QuestManager.availableRelics.Count; i++) { info.AddValue("availableRelics_" + i, QuestManager.availableRelics[i], typeof(ItemStack)); } info.AddValue("questTypeCompletion", questTypeCompletion, typeof(Dictionary <string, long>)); info.AddValue("newQuestTimer", QuestManager.getNewQuestTimer()); info.AddValue("questEquipTimer", QuestManager.getEquipTimer()); GuildManager.writeSaveData(ref info, ref context); StatisticsTracker.serializeAllStats(ref info, ref context); info.AddValue("currentGuildmaster", currentGuildmaster, typeof(Master)); DeepGoalsTypes.serialize(ref info, ref context); info.AddValue("ResearchManager.lastViewDate", ResearchManager.lastViewDate.ToLongTimeString()); TutorialManager.serialize(ref info, ref context); }
public PlayerInfo(SerializationInfo info, StreamingContext context) { //Main.instance.player.SetDefaultUpgrades(); #pragma warning disable 0168 try { Main.saveVersionFromDisk = info.GetInt32("SaveVersion"); } catch (Exception ex) { Main.saveVersionFromDisk = 0; } #pragma warning restore 0168 // To future self: this turned into a dirty hack // Because how how upgrades were handled // :( Main.instance.player.builtItems = new List <Industry>(); Main.instance.player.money = BigInteger.Parse(info.GetString("money")); Main.instance.player.moneyFloor = BigInteger.Parse(info.GetString("moneyFloor")); //StatisticsTracker.lifetimeMoney.setValue(BigInteger.Parse(info.GetString("lifetimeMoney"))); Main.instance.player.renown = BigInteger.Parse(info.GetString("renown")); Main.instance.player.totalRenown = BigInteger.Parse(info.GetString("totalRenown")); Main.instance.player.maxVendors = info.GetInt32("maxVendors"); Main.instance.player.currentVendors = info.GetInt32("currentVendors"); Main.instance.player.maxApprentices = info.GetInt32("maxApprentices"); if (Main.saveVersionFromDisk >= 6) { Main.instance.player.journeymen = info.GetInt32("journeymen"); } Main.instance.player.currentApprentices = info.GetInt32("currentApprentices"); Main.instance.player.totalQuestsCompletedRenown = info.GetInt64("totalQuestsCompleted"); Main.instance.player.questsCompletedRenown = info.GetInt64("questsCompleted"); if (Main.saveVersionFromDisk < 8) { Main.instance.player.skillPoints = info.GetInt32("skillPoints"); } else { Main.instance.player.skillPoints = BigInteger.Parse(info.GetString("skillPoints")); Main.instance.player.totalSkillPoints = BigInteger.Parse(info.GetString("totalSkillPoints")); } Main.instance.player.resetLevel = info.GetInt32("resetLevel"); Main.instance.player.researchTime = (float)info.GetDouble("researchTime"); int num; num = info.GetInt32("miscInventorySize"); //miscInventory = new List<ItemStack>(); for (int o = 0; o < num; o++) { Main.instance.player.miscInventory.Add((ItemStack)info.GetValue("miscInventory_" + o, typeof(ItemStack))); } num = info.GetInt32("unidentifiedRelicsSize"); //unidentifiedRelics = new List<ItemStack>(); for (int o = 0; o < num; o++) { Main.instance.player.unidentifiedRelics.Add((ItemStack)info.GetValue("unidentifiedRelics_" + o, typeof(ItemStack))); } num = info.GetInt32("builtItemsSize"); for (int o = 0; o < num; o++) { Industry temp; if (Main.saveVersionFromDisk >= 14) { string id = info.GetString("buildItemID_" + o); temp = (Industry)info.GetValue("builtItems_" + o, typeof(Industry)); Main.instance.player.industriesFromDisk.Add(new IndustryLoadWrapper(temp, id)); } else { int id = info.GetInt32("buildItemID_" + o); temp = (Industry)info.GetValue("builtItems_" + o, typeof(Industry)); Main.instance.player.industriesFromDisk.Add(new IndustryLoadWrapper(temp, id)); } } if (Main.saveVersionFromDisk >= 13) { FieldInfo[] fields = typeof(Industries).GetFields(); num = info.GetInt32("allIndustries"); for (int o = 0; o < num; o++) { if (Main.saveVersionFromDisk >= 14) { Industry item = GameRegistry.GetIndustryByID(info.GetString("allIndustriesID_" + o)); item.setGridPos(new Vector3((float)info.GetDouble("allIndustriesX_" + o), (float)info.GetDouble("allIndustriesY_" + o), 0)); if (Main.saveVersionFromDisk >= 17) { item.doAutobuild = info.GetBoolean("allIndustriesAB_" + o); item.autoBuildLevel = info.GetInt32("allIndustriesABLvl_" + o); item.autoBuildMagnitude = info.GetInt32("allIndustriesABMag_" + o); if (Main.saveVersionFromDisk >= 19) { item.startingVendors = info.GetInt32("allIndustriesABVend_" + o); } } } else { FieldInfo field = fields[o]; Industry item = (Industry)field.GetValue(null); item.setGridPos(new Vector3((float)info.GetDouble("allIndustriesX_" + o), (float)info.GetDouble("allIndustriesY_" + o), 0)); } } } num = info.GetInt32("activeQuestsSize"); //Debug.Log("Reading " + num + " active quests"); for (int o = 0; o < num; o++) { Quest temp = (Quest)info.GetValue("activeQuests_" + o, typeof(Quest)); //quest obstacle type data from disk isn't actually available yet Main.instance.player.activeQuestsFromDisk.Add(new QuestLoadWrapper(temp)); } num = info.GetInt32("availableQuestsSize"); //Debug.Log("Reading " + num + " available quests"); for (int o = 0; o < num; o++) { Quest temp = (Quest)info.GetValue("availableQuests_" + o, typeof(Quest)); //quest obstacle type data from disk isn't actually available yet Main.instance.player.questsFromDisk.Add(new QuestLoadWrapper(temp)); } num = info.GetInt32("availableRelicsSize"); for (int o = 0; o < num; o++) { QuestManager.availableRelics.Add((ItemStack)info.GetValue("availableRelics_" + o, typeof(ItemStack))); } if (Main.saveVersionFromDisk >= 10) { Main.instance.player._questTypeCompletion = (Dictionary <string, long>)info.GetValue("questTypeCompletion", typeof(Dictionary <string, long>)); } float f = (float)info.GetDouble("newQuestTimer"); QuestManager.LoadTimerFromSave(f); if (Main.saveVersionFromDisk >= 11) { QuestManager.setEquipTimer((float)info.GetDouble("questEquipTimer")); } if (Main.saveVersionFromDisk >= 2) { GuildManager.readSaveData(ref info, ref context); } if (Main.saveVersionFromDisk >= 7) { StatisticsTracker.deserializeAllStats(ref info, ref context); } if (Main.saveVersionFromDisk >= 8) { Main.instance.player.currentGuildmaster = (Master)info.GetValue("currentGuildmaster", typeof(Master)); } else { Main.instance.player.currentGuildmaster = new Master(); } if (Main.saveVersionFromDisk >= 12) { DeepGoalsTypes.deserialize(ref info, ref context); } if (Main.saveVersionFromDisk >= 22) { ResearchManager.lastViewDate = DateTime.Parse(info.GetString("ResearchManager.lastViewDate")); } TutorialManager.deserialize(ref info, ref context); }
public void reset() { foreach (Industry ind in builtItems) { ind.quantityStored = 0; ind.SetRawVendors(0); ind.setTimeRemaining(0); ind.level = 0; ind.consumeAmount = 0; foreach (IndustryInput input in ind.inputs) { Main.Destroy(input.arrow); } Main.Destroy(ind.craftingGridGO); ind.craftingGridGO = null; ind.apprentices = 0; ind.resetCache(); } currentApprentices = 0; currentVendors = 0; builtItems = new List <Industry>(); //Debug.Log("digits: " + digits); //double digitsCur = BigInteger.Log10(money / moneyFloor); //Debug.Log(renown + "," + totalRenown); BigInteger spentRenown = totalRenown - renown; //Debug.Log("before: " + lifetimeMoney); //TODO: Lifetime money -> renown calc is WRONG //Immediate reset after reseting will generate renown for doing NOTHING BigInteger newRenown = BigInteger.CubeRoot(StatisticsTracker.lifetimeMoney.value); BigInteger totRen = newRenown; newRenown -= StatisticsTracker.lastResetRenownGain.value; StatisticsTracker.lastResetRenownGain.setValue(totRen); //Debug.Log("totalRenown1: " + totalRenown); newRenown /= 10000; //Debug.Log("totalRenown2: " + totalRenown); //Debug.Log("end: " + totalRenown + " - " + spentRenown + " + " + questsCompleted + " + " + newRenown + " = " + (totalRenown - spentRenown + questsCompleted)); totalRenown += questsCompletedRenown + newRenown; renown = totalRenown - spentRenown; StatisticsTracker.lifetimeRenown.addValue(questsCompletedRenown + newRenown); //skillPoints += (int)digitsCur; //moneyFloor *= 2; money = GetStartingCash(); totalQuestsCompletedRenown = 0; questsCompletedRenown = 0; /*StatisticsTracker.questsCompleted.resetValue(); * StatisticsTracker.minQuestDifficulty.resetValue(); * StatisticsTracker.maxQuestDifficulty.resetValue();*/ StatisticsTracker.newLevelReset(); _questTypeCompletion.Clear(); if (StatisticsTracker.firstEnchantment.isAchieved()) { StatisticsTracker.maxQuestDifficulty.addValue(2); StatisticsTracker.minQuestDifficulty.addValue(1); } if (StatisticsTracker.firstGuildmaster.isAchieved()) { StatisticsTracker.maxQuestDifficulty.addValue(2); StatisticsTracker.minQuestDifficulty.addValue(1); } if (StatisticsTracker.relicsMade.value >= 1) { StatisticsTracker.maxQuestDifficulty.addValue(1); } if (StatisticsTracker.twentiethQuestCompleted.isAchieved()) { StatisticsTracker.maxQuestDifficulty.addValue(2); } GuildManager.resetAllUpgrades(); }