/// <summary> /// Add the specified item and count. /// </summary> /// <returns>The add.</returns> /// <param name="item">Item.</param> /// <param name="count">Count.</param> public InventorySlotInfo Add(ItemProfile item, int count = 1) { InventorySlotInfo slotInfo = null; int limit = m_Slots.Length; for (int i = 0; i < limit; i++) { if (m_Slots[i].Item == item) { slotInfo = m_Slots[i]; break; } } if (slotInfo == null) { for (int i = 0; i < limit; i++) { if (m_Slots[i] == null) { m_Slots[i] = new InventorySlotInfo(item, count); break; } } } else { slotInfo.Count += count; } return(slotInfo); }
/// <summary> /// Sets the limit. /// </summary> /// <param name="newLimit">New limit.</param> public void SetLimit(int newLimit) { int limit = m_Slots.Length; InventorySlotInfo[] tmpSlots = new InventorySlotInfo[limit]; for (int i = 0; i < limit; i++) { tmpSlots[i] = m_Slots[i]; } m_Slots = new InventorySlotInfo[newLimit]; for (int i = 0; i < limit; i++) { m_Slots[i] = tmpSlots[i]; } }