using System.Collections.Generic; using UnityEngine; [System.Serializable] public class InventoryData { [System.Serializable] public struct ItemInfo { public int itemID; public int slotPosition; public bool equipped; public int ownerID; }; public List<ItemInfo> leadEquipment = new List<ItemInfo>(); public List<ItemInfo> blueEquipment = new List<ItemInfo>(); public List<ItemInfo> greenEquipment = new List<ItemInfo>(); public List<ItemInfo> orangeEquipment = new List<ItemInfo>(); public List<ItemInfo> loadoutInventory = new List<ItemInfo>(); public int credits; public int datum; public InventoryData(InventoryManager manager) { for (int i = 0; i < 5; i++) //for each inventory being tracked { List<GameObject> currentManagerList = new List<GameObject>(); List<ItemInfo> currentInv = new List<ItemInfo>(); currentInv.Clear(); if (i == 0) currentManagerList = manager.leadEquipment; else if (i == 1) currentManagerList = manager.blueEquipment; else if (i == 2) currentManagerList = manager.greenEquipment; else if (i == 3) currentManagerList = manager.orangeEquipment; else if (i == 4) currentManagerList = manager.inventoryItems; if (currentManagerList.Count != 0) { for (int y = 0; y < currentManagerList.Count; y++) //for each item in the current list, set the item information { Item currentItem = currentManagerList[y].GetComponent<Item>(); ItemInfo newItem = new ItemInfo { itemID = currentItem.itemStats.ID, slotPosition = y, equipped = currentItem.itemStats.equipped }; if (currentItem.itemStats.leadOwns) newItem.ownerID = 0; else if (currentItem.itemStats.blueOwns) newItem.ownerID = 1; else if (currentItem.itemStats.greenOwns) newItem.ownerID = 2; if (currentItem.itemStats.orangeOwns) newItem.ownerID = 3; currentInv.Add(newItem); } } if (i == 0) leadEquipment = currentInv; else if (i == 1) blueEquipment = currentInv; else if (i == 2) greenEquipment = currentInv; else if (i == 3) orangeEquipment = currentInv; else if (i == 4) loadoutInventory = currentInv; } credits = manager.currency; datum = manager.currency1; } }