Beispiel #1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        laser laser = coll.gameObject.GetComponent <laser>();

        if (laser)
        {
            laser.hit();
            health -= laser.getdamage();
            if (health <= 0)
            {
                Destroy(gameObject);
                scores += 100;
            }
        }
    }
Beispiel #2
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        laser laser = coll.gameObject.GetComponent <laser>();

        if (laser)
        {
            laser.hit();
            health -= laser.getdamage();
            if (health == 1)
            {
                gameObject.GetComponent <SpriteRenderer>().sprite = seconddlife.GetComponent <SpriteRenderer>().sprite;
                scores += 50;
            }
            if (health <= 0)
            {
                Destroy(gameObject);
                scores += 100;
            }
        }
    }