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); }
public CartItem this[int i] { get { return(Items[i]); } set { if (i >= Count) { Count = i + 1; } Items[i] = value; CartChanged?.Invoke(); } }
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(); }
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)); }