public void Equip(int itemIndex, int equipSlot) { EquippableItem item = FreeInventory[itemIndex] as EquippableItem; if (item == null) { throw new NotSupportedException(); } switch (equipSlot) { case EquipSlot.SKILL1: case EquipSlot.SKILL2: case EquipSlot.SKILL3: case EquipSlot.SKILL4: case EquipSlot.SKILL5: case EquipSlot.SKILL6: if (item.Category != EquippableItem.SlotCategory.Skill) { throw new NotSupportedException(); } break; case EquipSlot.CLASS: if (item.Category != EquippableItem.SlotCategory.Class) { throw new NotSupportedException(); } break; case EquipSlot.PERK1: case EquipSlot.PERK2: case EquipSlot.PERK3: if (item.Category != EquippableItem.SlotCategory.Perk) { throw new NotSupportedException(); } break; default: throw new NotSupportedException(); } FreeInventory.RemoveAt(itemIndex); if (EquippedInventory[equipSlot] != null) { FreeInventory.Add(EquippedInventory[equipSlot]); } EquippedInventory[equipSlot] = item; OnEquipmentChanged(new EquipmentChangedEventArgs(equipSlot)); }
public EquipSlotMenu(EquippableItem item) { Item = item; EquipSlotMenuEntry equipEntry; switch (item.Category) { case EquippableItem.SlotCategory.Skill: for (int s = EquipSlot.SKILL1; s < EquipSlot.NUM_SKILL_SLOTS + EquipSlot.SKILL1; ++s) { equipEntry = new EquipSlotMenuEntry(EquipSlot.Names[s]); equipEntry.EquipSlot = s; equipEntry.Selected += EquipItemSelected; mMenuEntries.Add(equipEntry); } break; case EquippableItem.SlotCategory.Class: equipEntry = new EquipSlotMenuEntry(EquipSlot.Names[EquipSlot.CLASS]); equipEntry.EquipSlot = EquipSlot.CLASS; equipEntry.Selected += EquipItemSelected; mMenuEntries.Add(equipEntry); break; case EquippableItem.SlotCategory.Perk: for (int s = EquipSlot.PERK1; s < EquipSlot.NUM_PERK_SLOTS + EquipSlot.PERK1; ++s) { equipEntry = new EquipSlotMenuEntry(EquipSlot.Names[s]); equipEntry.EquipSlot = s; equipEntry.Selected += EquipItemSelected; mMenuEntries.Add(equipEntry); } break; default: throw new NotSupportedException(); } }
public EquippedInventoryMenuEntry(string text, EquippableItem item) : base(text) { Item = item; Text = "E* " + Text + " --- " + EquipSlot.Names[item.Owner.EquippedInventory.IndexOf(item)]; }