private void BuyItem()
        {
            if (_selectedEquipment != null)
            {
                Equipment.Remove(_selectedEquipment);
                using (var context = new MyEntities())
                {
                    if (_editItemWindow != null)
                    {
                        _editItemWindow.Close();
                    }
                    context.Ninjas.Attach(SelectedNinja.ToModel());
                    context.Equipments.Attach(_selectedEquipment.ToModel());

                    SelectedNinja.Equipment.Add(SelectedEquipment);
                    SelectedEquipment.ToModel().Ninjas.Add(SelectedNinja.ToModel());
                    SelectedNinja.GoldAmount -= _selectedEquipment.EquipmentPrice;

                    context.SaveChanges();
                }
                base.RaisePropertyChanged();
            }
            ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().UpdateItem();
            ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().TotalGold     += _selectedEquipment.EquipmentPrice;
            ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().TotalStrength += _selectedEquipment.EquipmentStrength;
            ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().TotalAgility  += _selectedEquipment.EquipmentAgility;
            ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().TotalIntel    += _selectedEquipment.EquipmentIntel;
        }
        private bool TryGetModel(out ModelDefinition model, out ModelVariantIdentifier variant)
        {
            model   = null;
            variant = default(ModelVariantIdentifier);
            if (SelectedEquipment == null)
            {
                return(false);
            }

            var charType = SelectedEquipment.GetModelCharacterType();

            if (charType == 0)
            {
                return(false);
            }
            try {
                model = SelectedEquipment.GetModel(charType, out variant.ImcVariant);
                if (SelectedEquipment.IsDyeable && SelectedStain != null)
                {
                    variant.StainKey = SelectedStain.Key;
                }

                var result = (model != null);
                if (!result)
                {
                    System.Windows.MessageBox.Show(string.Format("Unable to find model for {0} (c{1:D4}).", SelectedEquipment.Name, charType), "Model not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                }
                return(result);
            } catch (Exception e) {
                System.Windows.MessageBox.Show(string.Format("Failed to load model for {0} (c{1:D4}):{2}{3}", SelectedEquipment.Name, charType, Environment.NewLine, e), "Read failure", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return(false);
            }
        }
Exemple #3
0
 public DalSelectedEquipment MapToDal(SelectedEquipment entity)
 {
     return(new DalSelectedEquipment
     {
         Id = entity.id,
         EquipmentLib_id = entity.equipmentLib_id,
         Equipment_id = entity.equipment_id
     });
 }