Пример #1
0
    void Update()
    {
        TurrentScript TSC = TC.choosenPrefab.GetComponent <TurrentScript> ();

        //int price = TC.choosenPrefab.GetComponent<TurrentScript> ().price;	//getting the price of the choosen turrent
        int price = TSC.price;

        if (TSC.Level == 2)
        {
            price = (int)TSC.upgradePrice;
        }

        if (Money <= 0)                 //checking money for the noMoney Flag
        {
            noMoney = true;
        }
        else if (Money > 0)             //checking if you have enough money for the choosen turrent

        {
            if (Money >= price)
            {
                noMoney = false;
            }
            else
            {
                noMoney = true;
            }
        }


        if (turrentWasPlaced)           //controll for placing turrents
        {
            Money           -= price;
            turrentWasPlaced = false;
        }

        //TODO: can be deleted
        if (bulletKilledEnemy)          // -||- for getting money for enemy kills
        {
            Money            += 25;     //FIXME: price has somhow to increase with higher Wave numbers
            bulletKilledEnemy = false;
        }



        moneyText.text = Money.ToString() + " $";       //updating
    }
 void Start()
 {
     TS = transform.parent.GetComponent <TurrentScript> ();          //getting reference to turrent script , to acces hit var
 }