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