Exemple #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        LaserBullet bullet = collider.gameObject.GetComponent <LaserBullet>();

        if (bullet)
        {
            life -= bullet.GetDamage();
            if (life <= 0)
            {
                Die();
            }
            bullet.Hit();
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        LaserBullet bullet = collider.gameObject.GetComponent <LaserBullet>();

        if (bullet)
        {
            life -= bullet.GetDamage();
            scorePoint.addScore(hitScorePoint);
            if (life <= 0)
            {
                Destroy(gameObject);
                AudioSource.PlayClipAtPoint(dieSound, transform.position);
            }
            bullet.Hit();
        }
    }