Example #1
0
        public void Decrease(string classname, int amount = 1)
        {
            if (amount == 0)
            {
                return;
            }

            if (!items.TryGetValue(classname, out InventoryItemModel item))
            {
                UnityEngine.Debug.LogError(string.Format("Ассета нет в инвентаре classname : {0}", classname));
            }

            if (item.Amount < amount)
            {
                UnityEngine.Debug.LogError(string.Format("Недостаточно количества для уменьшения classname : {0}, amount : {1}, current_amount : {2}", classname, amount, items[classname]));
            }

            item.Decrease(amount);

            if (item.Amount == 0)
            {
                items.Remove(classname);
            }

            OnDecrease?.Invoke(item, item.Amount, amount, item.Amount == 0);
        }
Example #2
0
        private void DecreaseButton_Click(object sender, RoutedEventArgs e)
        {
            Value = (Value - 1) < MinValue ? MinValue : Value - 1;
            if (Value == MinValue)
            {
                DecreaseButton.IsEnabled = false;
            }
            else
            {
                IncreaseButton.IsEnabled = true;
            }

            OnDecrease?.Invoke();
        }
Example #3
0
 internal void Decrease(int amount)
 {
     Amount -= amount;
     OnDecrease?.Invoke(this, Amount, amount);
 }