public void LoadEquipItems() { if (File.Exists(Application.persistentDataPath + "/itemsData" + PlayerPrefs.GetInt("GameSlot") + ".dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/itemsData" + PlayerPrefs.GetInt("GameSlot") + ".dat", FileMode.Open); SerializationItems items = (SerializationItems)bf.Deserialize(file); file.Close(); equippedItems = items.equippedItemsSer; CalculateAttributes(); } }
public void SaveItemsBeginning(int slotNumber) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/itemsData" + slotNumber + ".dat"); SerializationItems items = new SerializationItems(); Item[] equippedItems = new Item[8]; Item[] storedItems = new Item[28]; Item[] shopItems = new Item[9]; equippedItems[0] = new Head("Common", 1, new ItemStatType.Stats[] { ItemStatType.Stats.MagicPower, ItemStatType.Stats.AttackSpeed }, new int[] { 160, 160, 160, 160 }); equippedItems[2] = new Staff("Common", 1, 320, new ItemStatType.Stats[] { ItemStatType.Stats.MagicPower }, new int[] { 160, 160 }); equippedItems[3] = new Robe("Common", 1, new ItemStatType.Stats[] { ItemStatType.Stats.Health, ItemStatType.Stats.AttackPower, ItemStatType.Stats.HealthRegen }, new int[] { 160, 160, 160, 160, 160 }); equippedItems[6] = new Boots("Common", 1, new ItemStatType.Stats[] { ItemStatType.Stats.AttackPower }, new int[] { 160, 160, 160, 160 }); items.equippedItemsSer = equippedItems; items.storedItemsSer = storedItems; items.shopItemsSer = shopItems; bf.Serialize(file, items); file.Close(); }