// unequips the specified item, returns true if successful public bool UnequipItem(int itemID) { ItemEquipment item = Equipment.SingleOrDefault(ie => ie.ID == itemID); if (item != null) { Equipment.Remove(item); AddItemToInventory(itemID); RecalculateStats(); return(true); } return(false); }
// equips the specified item, returns true if successful public bool EquipItem(int itemID) { InventoryItem item = Inventory.SingleOrDefault(ii => ii.ID == itemID); if (item != null && item.Data is ItemEquipment) { ItemEquipment itemEquipment = (ItemEquipment)item.Data; RemoveItemFromInventory(itemID); // remove equipped item occupying the same slot ItemEquipment itemInSlot = Equipment.SingleOrDefault(ie => ie.Type == itemEquipment.Type); if (itemInSlot != null) { UnequipItem(itemInSlot.ID); } Equipment.Add(itemEquipment); RecalculateStats(); return(true); } return(false); }
public bool HasTypeEquipped(EquipmentType type) { ItemEquipment item = Equipment.SingleOrDefault(ie => ie.Type == type); return(item != null); }