Example #1
0
 IEnumerator drainCoins()//drains the player's coins into the tree as the button is held down
 {
     while (ButtonLetGo == false)
     {
         if (coinScript.getCurrentCoins() > 0)                           //while the player still has some coins
         {
             int CoinsToDrain = 1 + (coinScript.getCurrentCoins() / 10); //drains coins faster for every 10 coins the player has
             coinScript.spendCoins(CoinsToDrain);                        //takes the coins away from the player
             updateCoinBar(CoinsToDrain);                                //added coins add to coin goal and update coin bar
             giveCoinsToTree(CoinsToDrain);                              //added coins are given to the tree
         }
         yield return(new WaitForSeconds(0.2f));
     }
 }
Example #2
0
    public Plant plantSeed()//returns the current seed held and buys a new one if possible, otherwise empties hand
    {
        Plant Sprout = CurrentSeedHeld;

        if (CurrentSeedHeld.Price > coinScript.getCurrentCoins())//if you can't afford a new seed, empty hand. Otherwise autobuys a new seed for easy planting
        {
            //hides held seed graphics and empties hand
            CurrentSeedHeld = null;
            HeldSeedDisplay.SetActive(false);
            HoldingSeed = false;
        }
        else
        {
            coinScript.spendCoins(CurrentSeedHeld.Price);//buys a new seed of the current plant
        }

        return(Sprout);
    }
Example #3
0
 void Update()
 {
     ShopCoinTxt.text = coinScript.getCurrentCoins().ToString();//updates the coins the player has that are displayed on the shop panel
 }