コード例 #1
0
 /// <summary>
 /// buying stuff in the bar
 /// </summary>
 /// <param name="other">Collider to see which item they are buying</param>
 private void OnTriggerStay(Collider other)
 {
     //if you press the buy button while next to the shop it will remove coins and give the player the buff
     if (other.gameObject.tag == "FullHealShop" && input.getBuyPressed && points.points >= fullHealPrice)
     {
         spendParticle.Play();
         gameObject.GetComponent <PlayerDamageHandler>().health = gameObject.GetComponent <PlayerDamageHandler>().maxHealth;
         points.LosePoints(fullHealPrice);
     }
     else if (other.gameObject.tag == "SpeedDrinkShop" && input.getBuyPressed && points.points >= speedUpPrice && gameObject.GetComponent <PlayerMoveScript>().shopSpeedIncrease < gameObject.GetComponent <PlayerMoveScript>().shopSpeedIncreaseLimit)
     {
         spendParticle.Play();
         this.gameObject.GetComponent <PlayerMoveScript>().shopSpeedIncrease += GetComponent <PlayerMoveScript>().moveSpeed / 5;
         points.LosePoints(speedUpPrice);
     }
     else if (other.gameObject.tag == "HealthIncreaseShop" && input.getBuyPressed && points.points >= healthUpPrice)
     {
         spendParticle.Play();
         gameObject.GetComponent <PlayerDamageHandler>().maxHealth++;
         gameObject.GetComponent <PlayerDamageHandler>().health++;
         points.LosePoints(healthUpPrice);
     }
     else if (other.gameObject.tag == "LivesUpShop" && input.getBuyPressed && points.points >= livesUpPrice)
     {
         spendParticle.Play();
         gameObject.GetComponent <PlayerDamageHandler>().lives++;
         points.LosePoints(livesUpPrice);
     }
 }