예제 #1
0
    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;
            }
        }
    }
예제 #2
0
 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);
     }
 }
예제 #3
0
 private bool CanBuy(ShopItemStandBehavior item)
 {
     return(item.GetStock() > 0 && item.GetPrice() >= _money);
 }