Esempio n. 1
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     // if the thing collided with is a player,
     if (collider.gameObject.name == "Player")
     {
         ReactorAttributes player = collider.gameObject.GetComponent <ReactorAttributes>();
         // give the player the electricity
         player.AddElectricity(amountOfElectricity);
         // play sound
         AudioSource.PlayClipAtPoint(source, Camera.main.transform.position, 0.50f);
         // and get rid of this pickupable
         Destroy(gameObject);
     }
 }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("HealthItem"))
        {
            currHealth = Mathf.Min(currHealth + maxHealth * 0.10f, maxHealth);
        }
        else if (other.CompareTag("ElectricityItem"))
        {
            stats.AddElectricity(stats.GetMaxElectricity() * 0.10f);
        }
        else
        {
            return;
        }

        Destroy(other.gameObject);
    }