private void UnEquipItem(Model.CharacterRelated.InventoryRelated.Item item) { if (item is Model.CharacterRelated.InventoryRelated.WeaponSlot) { Inventory.Add(Equipped.Weapon); Weapon.SelectedCommand = new DelegateCommand(x => EquipItem(item)); Items.Add(Weapon); Equipped.Weapon = null; Weapon = new Fields.ItemField { Name = "Weapon Slot", ImageName = "", Stats = "None.", SelectedCommand = new DelegateCommand(x => {}) }; OnPropertyChanged("Weapon"); OnPropertyChanged("Items"); } else if (item is Model.CharacterRelated.InventoryRelated.ArmorSlot) { Inventory.Add(Equipped.Armor); Armor.SelectedCommand = new DelegateCommand(x => EquipItem(item)); Items.Add(Armor); Equipped.Armor = null; Armor = new Fields.ItemField { Name = "Armor Slot", ImageName = "", Stats = "None.", SelectedCommand = new DelegateCommand(x => { }) }; OnPropertyChanged("Armor"); OnPropertyChanged("Items"); } }
private void EquipItem(Model.CharacterRelated.InventoryRelated.Item item) { if (item is Model.CharacterRelated.InventoryRelated.WeaponSlot) { if (Equipped.Weapon != null) { Inventory.Add(Equipped.Weapon); Weapon.SelectedCommand = new DelegateCommand(x => EquipItem(Equipped.Weapon)); Items.Add(Weapon); } Inventory.Remove(item); Equipped.Weapon = (Model.CharacterRelated.InventoryRelated.WeaponSlot)item; Fields.ItemField f = Items.Where(i => i.Name == item.Name).First(); Items.Remove(f); f.SelectedCommand = new DelegateCommand(x => UnEquipItem(item)); Weapon = f; OnPropertyChanged("Weapon"); OnPropertyChanged("Items"); } else if (item is Model.CharacterRelated.InventoryRelated.ArmorSlot) { if (Equipped.Armor != null) { Inventory.Add(Equipped.Armor); Armor.SelectedCommand = new DelegateCommand(x => EquipItem(Equipped.Armor)); Items.Add(Armor); } Inventory.Remove(item); Equipped.Armor = (Model.CharacterRelated.InventoryRelated.ArmorSlot)item; Fields.ItemField f = Items.Where(i => i.Name == item.Name).First(); Items.Remove(f); f.SelectedCommand = new DelegateCommand(x => UnEquipItem(item)); Armor = f; OnPropertyChanged("Armor"); OnPropertyChanged("Items"); } }