Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        rubyController player = other.gameObject.GetComponent <rubyController>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
Exemplo n.º 2
0
    void OnTriggerStay2D(Collider2D other)
    {
        rubyController controller = other.GetComponent <rubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        rubyController controller = other.GetComponent <rubyController>();

        if (controller != null)
        {
            if (controller.health < controller.maxHealth)
            {
                controller.ChangeHealth(1);
                Destroy(gameObject);

                controller.PlaySound(collectedClip);
            }
        }
    }