예제 #1
0
    public void BuyItem()
    {
        if (Item == null)
        {
            return;
        }

        var item   = Item;
        var player = PlayerController.Instance;

        if (player.CurrentGold >= item.Price)
        {
            player.CurrentGold -= item.Price;
            var builtItem = ItemInstanceBuilder.BuildInstance(item.Item, ShopMenu.Shop.forceDefaults);
            player.AddItemToInventory(builtItem);
            ShopMenu.UpdateGoldText();
        }
        else
        {
            Debug.LogError("Insufficient Gold");
        }
    }