コード例 #1
0
    public void onBuyButtonClicked(AudioSource audio)
    {
        item = ListBank.Instance.itemToBuy;
        if (checkCoins(coin) && buttonActivate)
        {
            //FAZER LOGICA PARA RETIRAR ITEMS(!STACKABLE) DA LOJA DPS DE COMPRADOS

            //som quando comprar item
            audio.Play();

            coin -= item.Value;
            CoinsPanel.GetComponent <Text> ().text = "x " + coin.ToString();

            if (item.Ability)
            {
                behave.abilityIDs[behave.abilityIndex] = item.ID;
                behave.abilityIndex++;
            }
            else if (item.ID == 5)               // BALAS DA MP9
            {
                behave.bullets[1] += 30;
            }
            else if (item.ID == 6)              // BALAS DA SHOTGUN
            {
                behave.bullets[2] += 8;
            }
            else
            {
                behave.inventory[item.ID]++;
            }
            behave.coins = coin;
            behave.CheckWeaponAchievements();

            if (behave.showTutorial)
            {
                if (item.ID == 0)
                {
                    pistolPurchased = true;
                    indexToBuy      = 1;
//					storeCanvasPanel.SetActive(true);
//					StopCoroutine(BlinkArrow());
                    StartCoroutine(ShowMessage("buy 5 waters"));
                    leftBuyArrow.GetComponent <Image>().color  = Color.clear;
                    rightBuyArrow.GetComponent <Image>().color = Color.clear;
//					StartCoroutine(Blink(false,false,true,"buy 5 waters"));
                }
                if (item.ID == 1)
                {
                    waterCount--;
                    if (waterCount == 0)
                    {
                        watersPurchased = true;
//						StopCoroutine(BlinkArrow());
                    }
                }
            }
        }
        else
        {
            print("can't buy");
        }


        var x = GetComponentsInChildren <ListBox> ();

        foreach (ListBox box in x)
        {
            print("buy");
            box.updateSize();
        }
    }