Esempio n. 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("meteorite"))
        {
            Meteorito meteorite = collision.gameObject.GetComponent <Meteorito>();

            if (meteorite != null)
            {
                FindObjectOfType <Score>().AddPoints(10);
                Destroy(collision.gameObject);
                Destroy(this.gameObject);
                meteorite.DestroyMeteorite();
                Destroybullet();
            }
        }

        if (collision.gameObject.CompareTag("Enemigo"))
        {
            Enemigo enemigo = collision.gameObject.GetComponent <Enemigo>();

            if (enemigo != null)
            {
                FindObjectOfType <Score>().AddPoints(10);
                Destroy(collision.gameObject);
                Destroy(this.gameObject);
                enemigo.DestroyEnemy();
                Destroybullet();
            }
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Player player = collision.gameObject.GetComponent <Player>();

        if (player != null)
        {
            player.Damage(damageAmount);
            Destroy(this.gameObject);
        }
        if (collision.gameObject.CompareTag("meteorite"))
        {
            Meteorito meteorite = collision.gameObject.GetComponent <Meteorito>();

            if (meteorite != null)
            {
                FindObjectOfType <Score>().AddPoints(10);
                Destroy(collision.gameObject);
                Destroy(this.gameObject);
            }
        }
    }