コード例 #1
0
        /// <summary>
        /// Купить награду
        /// </summary>
        /// <param name="_pers">Персонаж</param>
        /// <param name="costProperty">Цена награды</param>
        public void BuyReward(Pers _pers, int costProperty)
        {
            StaticMetods.PlaySound(Properties.Resources.coin);
            var editableReward = this;
            ObservableCollection <Revard> shopItems = _pers.ShopItems;

            List <Revard> uni = (_pers.InventoryItems.Union(_pers.ShopItems)).ToList();

            var vc = new ViewChangesClass(uni);

            vc.GetValBefore();

            _pers.GoldProperty -= costProperty;
            _pers.InventoryItems.Add(editableReward);

            vc.GetValAfter();

            var   header            = $"{editableReward.GetTypeOfRevard()} \"{editableReward.NameOfProperty}\" добавлен в инвентарь!!!";
            Brush col               = Brushes.Green;
            var   itemImageProperty = StaticMetods.pathToImage(Path.Combine(Directory.GetCurrentDirectory(), "Images", "good.png"));

            vc.ShowChanges(header, col, itemImageProperty);

            if (editableReward.IsArtefact)
            {
                shopItems.Remove(editableReward);
            }

            StaticMetods.AbillitisRefresh(_pers);
            StaticMetods.refreshShopItems(_pers);
        }
コード例 #2
0
        /// <summary>
        /// Редактирование награды
        /// </summary>
        /// <param name="item"></param>
        public static void EditReward(Revard item)
        {
            var showRevard = new AddOrEditRevard
            {
                // Topmost = true,
                btnOk     = { Visibility = Visibility.Visible },
                btnAdd    = { Visibility = Visibility.Collapsed },
                btnCansel = { Visibility = Visibility.Collapsed }
            };

            var showRevardVM = new AddOrEditRevardViewModel(item, false, false);

            showRevard.DataContext = showRevardVM;

            showRevard.btnOk.Click += (sender, args) => { showRevard.Close(); };
            var HotSaveCommand = new RelayCommand(() =>
            {
                showRevard.Close();
            });

            showRevard.InputBindings.Add(new KeyBinding(HotSaveCommand,
                                                        new KeyGesture(Key.S,
                                                                       ModifierKeys.Control)));

            showRevard.ShowDialog();
            StaticMetods.refreshShopItems(StaticMetods.PersProperty);
        }
コード例 #3
0
 private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
 {
     StaticMetods.refreshShopItems(StaticMetods.PersProperty);
 }