public bool IsEquiped(IEquipableItem item) { switch (item) { case IHoldableItem holdableItem: return((rightHandItem != null && rightHandItem.Equals(holdableItem)) || (leftHandItem != null && leftHandItem.Equals(holdableItem))); case IArmorItem armorItem: return(Armor[armorItem.ArmorType] != null && Armor[armorItem.ArmorType].Equals(item)); case SpellBook spellBookItem: return(SpellBook != null && SpellBook.Equals(spellBookItem)); default: throw new ArgumentException($"Equipable item type is not supported: {item.GetType().FullName}"); } }
public void EquipItem(IEquipableItem item) { switch (item) { case IHoldableItem _: throw new ArgumentException($"Weapon items should be equiped with {nameof(EquipHoldable)}"); case IArmorItem armorItem: EquipArmor(armorItem); break; case SpellBook spellBookItem: EquipSpellBook(spellBookItem); break; default: throw new ArgumentException($"Equipable item type is not supported: {item.GetType().FullName}"); } }
public void UnequipItem(IEquipableItem item) { switch (item) { case IHoldableItem holdableItem: UnequipHoldable(holdableItem); break; case IArmorItem armorItem: UnequipArmor(armorItem.ArmorType); break; case SpellBook _: UnequipSpellBook(); break; default: throw new ArgumentException($"Equipable item type is not supported: {item.GetType().FullName}"); } }