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); }
/// <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()); }
public void СountTurn() { _currentTurnsAmount--; AmountChanged?.Invoke(_currentTurnsAmount); }
public TurnsCounter(int turnsForGame) { _currentTurnsAmount = turnsForGame; AmountChanged?.Invoke(_currentTurnsAmount); }
protected void OnAmountChange(ValueChangedEventArgs <int> eventArgs) => AmountChanged?.Invoke(this, eventArgs);