Exemplo n.º 1
0
    //--------------------------------------------------------------------------
    //--- BUY ITEMS ---
    //--------------------------------------------------------------------------
    //Button click
    public void OnBuyItemClick()
    {
        PlayerMoney playerMoney = GameObject.FindGameObjectWithTag("MoneyManager").GetComponent <PlayerMoney>();

        if (playerMoney.getBalance() > avatarElements[currentSelectedSprite].price)
        {
            //Reduce balane
            playerMoney.pay(avatarElements[currentSelectedSprite].price);

            //Oficially desclare item bought
            avatarElements[currentSelectedSprite].isOwned = true;

            //Remember that this item is owned
            boughtItemsScript.AddItemToCategory(GetComponent <CategorySelection>().currentCategory, currentSelectedSprite);

            //Change selection item
            ModifySelectionItem();

            //Audio
            audioManager.PlayCoins();
        }
        else
        {
            //Audio
            audioManager.PlayTooExpensive();
        }
    }