Пример #1
0
 public void Add(Item newItem)
 {
     if (items.Count < slots)
     {
         items.Add(newItem);
     }
     if (onChange != null)
     {
         onChange.Invoke();
     }
     else
     {
         Debug.Log("No hay espacio en el inventario");
     }
 }
Пример #2
0
 public void Add(Item newItem)
 {
     if (items.Count < space)
     {
         items.Add(newItem);
         if (onChange != null)
         {
             onChange.Invoke();
         }
     }
     else
     {
         Debug.Log("No hay espacio disponible");
     }
 }
Пример #3
0
 public void Add(Item item)
 {
     if (items.Count < space)
     {
         items.Add(item);
         if (onChange != null)
         {
             onChange.Invoke();
         }
     }
     else
     {
         Debug.LogWarning("Espacio insuficiente!");
     }
 }
Пример #4
0
 //Calls necessary observer methods when the value gets flatly added to
 public void setValue(float val)
 {
     if (val == 0)
     {
         return;
     }
     if (val > 0)
     {
         OnIncrement.Invoke(val);
     }
     else if (val < 0)
     {
         OnDecrement.Invoke(val);
     }
     value = val;
     OnChange.Invoke(val);
     if (ValueAsBool())
     {
         OnTrue.Invoke();
     }
     else
     {
         OnFalse.Invoke();
     }
 }
Пример #5
0
 protected void fireOnChange(TKey key)
 {
     if (OnChange != null)
     {
         OnChange.Invoke(key);
     }
 }
Пример #6
0
 private void InvokeOnChange()
 {
     if (OnChange != null)
     {
         OnChange.Invoke(this, EventArgs.Empty);
     }
 }
Пример #7
0
 public void MarkAsDirty()
 {
     if (OnChange != null)
     {
         OnChange.Invoke(this);
     }
 }
Пример #8
0
        public void Update()
        {
#if DEBUG
            var oldIsNight     = IsNight;
            var oldIsBloodMoon = IsBloodMoon;
            var oldZombieSpeed = ZombieSpeed;
#endif
            var world = GameManager.Instance.World;
            IsNight     = world.IsDark();
            IsBloodMoon = SkyManager.BloodMoon();
            ZombieSpeed = CalculateZombieSpeed();
#if DEBUG
            if (oldIsNight != IsNight)
            {
                Logger.Debug("isNight, Old: {0}, New: {1}", oldIsNight, IsNight);
            }
            if (oldIsBloodMoon != IsBloodMoon)
            {
                Logger.Debug("isBloodMoon, Old: {0}, New: {1}", oldIsBloodMoon, IsBloodMoon);
            }
            if (oldZombieSpeed != ZombieSpeed)
            {
                Logger.Debug("zombieSpeed, Old: {0}, New: {1}", oldZombieSpeed, ZombieSpeed);
            }
#endif
            if (_invalidated)
            {
                if (OnChange != null)
                {
                    OnChange.Invoke();
                }
                _invalidated = false;
            }
        }
Пример #9
0
 /// <summary>
 /// publish paper
 /// </summary>
 public void ChangeData()
 {
     if (null != OnChange)
     {
         OnChange.Invoke("new data");
     }
 }
Пример #10
0
    public void Dequip(EquipableItem item)
    {
        if (helmet == item)
        {
            helmet = null;
        }
        if (chest == item)
        {
            chest = null;
        }
        if (gloves == item)
        {
            gloves = null;
        }
        if (boots == item)
        {
            boots = null;
        }
        if (weapon == item)
        {
            weapon = null;
        }
        if (accessory == item)
        {
            accessory = null;
        }

        if (OnChange != null)
        {
            Debug.Log("hero equipment changed");
            OnChange.Invoke(this);
        }
    }
Пример #11
0
 public void AddItem(string name, int amount = 1)
 {
     if (!this.Contains(name))
     {
         elements.Add(new InventoryElement(name, amount));
     }
     else
     {
         if (this[name].Amount + amount >= 0)
         {
             this[name].Amount += amount;
         }
         else
         {
             throw new ArgumentException("removing more items then there are");
         }
     }
     if (this[name].Amount == 0)
     {
         elements.Remove(this[name]);
     }
     if (OnChange != null)
     {
         OnChange.Invoke();
     }
 }
Пример #12
0
 public void Validate()
 {
     if (OnChange != null)
     {
         OnChange.Invoke();
     }
 }
Пример #13
0
 internal void Changed()
 {
     if (OnChange != null)
     {
         OnChange.Invoke(Gesture, this);
     }
 }
Пример #14
0
 private void Change(object subject)
 {
     if (OnChange != null)
     {
         OnChange.Invoke(subject, EventArgs.Empty);
     }
 }
Пример #15
0
        public void TriggerAll()
        {
            if (OnChange == null)
            {
                return;
            }

            var changes = new List <DataChange>();

            foreach (KeyValuePair <int, string> entry in fieldsByIndex)
            {
                var field = entry.Value;
                if (this[field] != null)
                {
                    changes.Add(new DataChange
                    {
                        Field         = field,
                        Value         = this[field],
                        PreviousValue = null
                    });
                }
            }

            OnChange.Invoke(this, new OnChangeEventArgs(changes));
        }
Пример #16
0
 private async Task NotifyStateChanged()
 {
     if (OnChange != null)
     {
         await OnChange.Invoke();
     }
 }
Пример #17
0
 public void InvokeOnChange(object item, object index)
 {
     if (OnChange != null)
     {
         OnChange.Invoke(this, new KeyValueEventArgs <T, string>((T)item, (string)index));
     }
 }
Пример #18
0
 void OnValidate()
 {
     if (OnChange != null)
     {
         OnChange.Invoke(this, EventArgs.Empty);
     }
 }
Пример #19
0
        public async Task AddToCart(CartItem item)
        {
            var cart = await _localStorage.GetItemAsync <List <CartItem> >("cart");

            if (cart == null)
            {
                cart = new List <CartItem>();
            }

            var sameItem = cart.Find(x => x.ProductId == item.ProductId && x.PurchaseOptionId == item.PurchaseOptionId);

            if (sameItem == null)
            {
                cart.Add(item);
            }
            else
            {
                sameItem.Quantity += item.Quantity;
            }

            await _localStorage.SetItemAsync("cart", cart);

            var product = await _productService.GetProduct(item.ProductId);

            _toastService.ShowSuccess(product.Title, "Added to your shopping cart:");

            OnChange.Invoke();
        }
Пример #20
0
 public async Task Update()
 {
     if (OnChange != null)
     {
         await OnChange.Invoke();
     }
 }
Пример #21
0
 public void SetValue(float value)
 {
     _value = value;
     if (OnChange != null)
     {
         OnChange.Invoke(_value);
     }
 }
Пример #22
0
        public void RemoveAt(int index)
        {
            T item = list[index];

            list.RemoveAt(index);
            OnRemove.Invoke(item);
            OnChange.Invoke(default(T));
        }
Пример #23
0
 public void TakeDamage(int amount)
 {
     _current -= amount;
     OnChange.Invoke();
     if (_current <= 0)
     {
         OnEmpty.Invoke();
     }
 }
Пример #24
0
 public bool Add(Item item)
 {
     if (OnChange != null && item != null)
     {
         items.Add(item);
         OnChange.Invoke(this);
     }
     return(true);
 }
Пример #25
0
 public void Remove(T item)
 {
     if (Value.Contains(item))
     {
         Value.Remove(item);
         OnChange.Invoke(item);
         OnRemove.Invoke(item);
     }
 }
Пример #26
0
 public bool Remove(Item item)
 {
     if (items.Remove(item) && item != null)
     {
         OnChange.Invoke(this);
         return(true);
     }
     return(false);
 }
Пример #27
0
 public void Set(T value)
 {
     if (under.Equals(value))
     {
         return;
     }
     onChange.Invoke(under, value);
     under = value;
 }
Пример #28
0
 public void Add(T item, bool silently = false)
 {
     list.Add(item);
     if (!silently)
     {
         OnAdd.Invoke(item);
         OnChange.Invoke(item);
     }
 }
Пример #29
0
 public void Add(T item)
 {
     if (!Value.Contains(item))
     {
         Value.Add(item);
         OnAdd.Invoke(item);
         OnChange.Invoke(item);
     }
 }
Пример #30
0
 public void AddRange(IEnumerable <T> items)
 {
     foreach (var item in items)
     {
         Add(item, true);
         OnAdd.Invoke(item);
     }
     OnChange.Invoke(default(T));
 }