public void TryBuyItem(ShopItemStandBehavior item) { if (CanBuy(item)) { switch (item.GetItemType()) { case ItemType.FOOD: _slot_health++; item.TakeOne(); _money -= item.GetPrice(); break; case ItemType.BASEBALL_BAT: if (!_has_baseball_bat) { _money -= item.GetPrice(); item.TakeOne(); _has_baseball_bat = true; } else { Debug.Log("Already has a bat"); } break; } } }
private void GenerateStands() { foreach (ItemBase ib in _base_items) { ShopItemStandBehavior sis = Instantiate(_itemStandPrefab, Vector3.forward, Quaternion.identity); sis.Init(ib.item_type, ib.base_price, ib.stock, ib.name, ib.description, ib.sprite); _stands.Add(sis); } }
private bool CanBuy(ShopItemStandBehavior item) { return(item.GetStock() > 0 && item.GetPrice() >= _money); }