public void LoadInventory(InventoryManger _inventoryManager) { ItemContainerSaveData savedSlots = ItemSaveIO.LoadItems(InventoryFileName); if (savedSlots == null) { return; } _inventoryManager.inventory.Clear(); for (int i = 0; i < savedSlots.savedSlots.Length; i++) { ItemSlot itemSlot = _inventoryManager.inventory.itemSlots[i]; ItemSlotSaveData savedSlot = savedSlots.savedSlots[i]; if (savedSlot == null) { itemSlot.Item = null; itemSlot.Amount = 0; } else { itemSlot.Item = m_itemDataBase.GetItemCopy(savedSlot.itemID); itemSlot.Amount = savedSlot.amount; itemSlot.eSlotState = savedSlot.slotState; itemSlot.SetStart(); } } }
public List <Item> GetCopyOfItems(ItemDataBase itemDataBase) { List <Item> items = new List <Item>(); foreach (ItemSlotSaveData itemSlotSaveData in savedSlots) { for (int i = 0; i < itemSlotSaveData.amount; i++) { Item item = itemDataBase.GetItemCopy(itemSlotSaveData.itemId); items.Add(item); } } return(items); }
public List <Item> LoadInventory(string fileName) { ItemContainerSaveData itemContainer = JsonSaveLoadIO.LoadItems(fileName); List <Item> items = new List <Item>(); foreach (ItemSlotSaveData itemSlotSave in itemContainer.savedSlots) { if (itemSlotSave != null) { items.Add(itemDataBase.GetItemCopy(itemSlotSave.itemId)); } } return(items); }