Exemplo n.º 1
0
    private void ChangeCart(int index)
    {
        _currentCart = _carts[index];

        GetComponent <SpriteRenderer>().sprite = _currentCart.Icon;

        Vector2 colliderBoundsVector = gameObject.GetComponent <SpriteRenderer>().sprite.bounds.size;

        gameObject.GetComponent <BoxCollider2D>().size = colliderBoundsVector;

        CartChanged?.Invoke(_currentCart);
    }
Exemplo n.º 2
0
 public CartItem this[int i]
 {
     get { return(Items[i]); }
     set
     {
         if (i >= Count)
         {
             Count = i + 1;
         }
         Items[i] = value;
         CartChanged?.Invoke();
     }
 }
Exemplo n.º 3
0
 public void Push(DBEntities.Dish dish, int count)
 {
     for (int i = 0; i < _items.Length; i++)
     {
         if (_items[i].Dish.Id == dish.Id)
         {
             _items[i].Count += count;
             return;
         }
     }
     this[Count] = new CartItem()
     {
         Dish  = dish,
         Count = count
     };
     CartChanged?.Invoke();
 }
Exemplo n.º 4
0
        public void Remove(int id)
        {
            bool move = false;

            for (int i = 0; i < Count; i++)
            {
                if (this[i].Dish.Id == id)
                {
                    move = true;
                }
                if (move && i != Count - 1)
                {
                    this[i] = this[i + 1];
                }
            }
            if (move)
            {
                Count--;
            }
            CartChanged?.Invoke();
        }
 public void RaiseCartChanged()
 {
     CartChanged?.Invoke(this, new CartChangedEventArgs(Cart));
 }