public string AddItemNEW(int itemId) { if (inventorySpace.Value < inventorySpace.GetCap()) { IItem item = ItemDBCache.GetItem(itemId); if (item != null) { switch (item.Type) { case ItemType.Weapon: case ItemType.Armor: Inventories[ItemType.Armor].Add(item); break; case ItemType.Consumable: Inventories[ItemType.Consumable].Add(item); break; case ItemType.Material: Inventories[ItemType.Material].Add(item); break; default: throw new InvalidEnumArgumentException("Unknown itemType enum passed to ItemHolder::AddNewItem"); } inventorySpace.PutOne(); } } return(string.Format("+item {0}, slot {1}", ItemDBCache.GetItem(itemId).Name, inventorySpace.Value - 1)); }
public string AddItem(int itemId) { if (_usedInventorySlots < InventorySlots) { IItem item = ItemDBCache.GetItem(itemId); if (item != null) { if (item.Type == ItemType.Weapon || item.Type == ItemType.Armor) { _inventory.Add(++_usedInventorySlots, item); } else { } } } return(string.Format("+item {0}, slot {1}", ItemDBCache.GetItem(itemId).Name, _usedInventorySlots)); }
//for initial loading public void EquipItemOnRestore(int itemId) { if (!ItemDBCache.Items.ContainsKey(itemId)) { return; } var item = ItemDBCache.GetItem(itemId); if (_equipment.ContainsKey(item.Slot)) { _equipment[item.Slot] = item; } else { _equipment.Add(item.Slot, item); } }