예제 #1
0
    /// <summary>
    /// Attempt to buy an item from the shop, if the player has enough money
    /// </summary>
    /// <param name="itemToBuy"></param>
    public void AttemptItemBuy(ShopItem itemToBuy)
    {
        if (player.Coins < itemToBuy.cost)
        {
            return;
        }

        // Enables the cancel and comfirm purchase buttons for the user
        cancelPurchaseButton.SetActive(true);
        comfirmPurchaseButton.SetActive(true);

        // If the current item is a tower, show preview
        if (itemToBuy.item.GetComponent <Tower>() && currentItem == itemToBuy && !towerManager.selectedTower.purchased)
        {
            CancelItemPurchase();
            currentItem = null;
        }
        else if (itemToBuy.item.GetComponent <Tower>()) //TODO Make it so it checks if the current tower is placed already and if it is then create a new tower
        {
            towerManager.BuildTower(itemToBuy.item);
            currentItem = itemToBuy;
        }
        else
        {
            currentItem = itemToBuy;
        }
    }
예제 #2
0
    /// <summary>
    /// Attempt to buy an item from the shop, if the player has enough money
    /// </summary>
    /// <param name="itemToBuy"></param>
    public void AttemptItemBuy(ShopItem itemToBuy)
    {
        if (player.Coins < itemToBuy.cost)
        {
            return;
        }

        // Enables the cancel and comfirm purchase buttons for the user
        ToggleButtons(true);

        // If the current item is a tower, show preview
        if (currentItem == itemToBuy && !towerManager.selectedTower.IsPurchased())
        {
            CancelItemPurchase();
            currentItem = null;
        }
        else
        {
            if (itemToBuy.item.GetComponent <Tower>())
            {
                towerManager.BuildTower(itemToBuy.item);
            }

            currentItem = itemToBuy;
        }
    }