public void Load(bool wasDead = false) { //Debug.Log("load land"); if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { //Debug.Log("found file"); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); PlayerData data = (PlayerData)bf.Deserialize(file); file.Close(); DestroyAllPlayerPossessionsInBags(); DestroyAllCurrentlyEquippedGear(); DestroyAllNonDefaultBags(); ExperienceManager.instance.experience = 0; //Talents PlayerTalents.instance.MyProjectile = data.projectile; // Load Stats PlayerController.instance.speed = normalSpeed; playerStats.MyCurrentHealth = 0; playerStats.MyMaxHealth = data.maxHealth; playerStats.Heal((int)data.currentHealth); ExperienceManager.MyLevel = data.level; ExperienceManager.instance.experienceRequired = data.experienceNeeded; playerStats.Agi.SetValue(data.Agility); playerStats.Sta.SetValue(data.Stamina); playerStats.Str.SetValue(data.Strength); playerStats.damage.SetValue(data.Damage); playerStats.armor.SetValue(data.Armor); playerStats.UpdateStats(); ExperienceManager.instance.AddExpFromLoadedGame(data.experience); StoryManager.questLine = data.questLine; StoryManager.stage = data.stage; StoryManager.givenItems = data.givenItems; StoryManager.tutorialStage = data.tutorialConversation; // bags LoadBags(data.amountOfBags, data.amountOfSlotsPerBag); // currently equipped items LoadEquippedItems(data.equippedItems); // items in bags LoadAllItemsInBags(data.itemsInTheSlot, data.amountOfStackableItemsPerSlot); // currency CurrencyManager.wealth = data.gold; // action bars Item tmp = InventoryScript.instance.FindItemInInventory(data.actionbar1); if (tmp != null) { actionbar1.LoadGameUseable(tmp as IUseable, tmp); } tmp = InventoryScript.instance.FindItemInInventory(data.actionbar2); if (tmp != null) { actionbar2.LoadGameUseable(tmp as IUseable, tmp); } tmp = InventoryScript.instance.FindItemInInventory(data.actionbar3); if (tmp != null) { actionbar3.LoadGameUseable(tmp as IUseable, tmp); } // statics dungeonFloorsExplored = data.dungeonFloorsExplored; enemiesKilled = data.enemiesKilled; ripostes = data.ripostes; blocks = data.blocks; hits = data.hits; fullChargeHits = data.fullChargeHits; arrowsFired = data.arrowsFired; randomizedItemsDropped = data.randomizedItemsDropped; SceneManager.LoadScene(data.zone.ToString()); player.transform.position = new Vector2(data.locationX, data.locationY); if (wasDead) { ResetStaticData(); } } }