public void Set(string name, int amount)
        {
            if (!Items.ContainsKey(name))
            {
                Items.Add(name, new InventoryData()
                {
                    Item = name
                });
            }

            Items[name].Amount = amount;

            if (AmountChanged != null)
            {
                AmountChanged.Invoke(this, new InventoryEventArgs(Items[name], amount));
            }
        }
        public bool Add(string name, int amount)
        {
            if (!Items.ContainsKey(name))
            {
                Items.Add(name, new InventoryData()
                {
                    Item = name
                });
            }

            Items[name].Amount += amount;

            if (AmountChanged != null)
            {
                AmountChanged.Invoke(this, new InventoryEventArgs(Items[name], amount));
            }

            // in future check for restrictions like a max amount of inventory space
            return(true);
        }
Exemple #3
0
 /// <summary>
 /// Handles a click event for IncrementBUtton
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnIncrementClicked(object sender, RoutedEventArgs e)
 {
     Amount++;
     AmountChanged?.Invoke(this, new EventArgs());
 }
Exemple #4
0
 public void СountTurn()
 {
     _currentTurnsAmount--;
     AmountChanged?.Invoke(_currentTurnsAmount);
 }
Exemple #5
0
 public TurnsCounter(int turnsForGame)
 {
     _currentTurnsAmount = turnsForGame;
     AmountChanged?.Invoke(_currentTurnsAmount);
 }
 protected void OnAmountChange(ValueChangedEventArgs <int> eventArgs) => AmountChanged?.Invoke(this, eventArgs);