Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        projectile missile = col.gameObject.GetComponent <projectile>();

        if (missile)
        {
            health -= missile.getDamage();
            missile.Hit();
            if (health <= 0)
            {
                Die();
            }
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log("Player has been hit");
        projectile missile = col.gameObject.GetComponent <projectile>();

        if (missile)
        {
            health -= missile.getDamage();
            missile.Hit();
            if (health <= 0)
            {
                Die();
            }
        }
    }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        projectile bullet = collider.gameObject.GetComponent <projectile> ();

        if (bullet)
        {
            hp -= bullet.GetDmg();
            bullet.Hit();
            if (hp <= 0)
            {
                Destroy(gameObject);
                keeper.Score(score);
                AudioSource.PlayClipAtPoint(deathSound, transform.position);
            }
        }
    }
Exemplo n.º 4
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        projectile bullet = collider.gameObject.GetComponent <projectile> ();

        if (bullet)
        {
            hp -= bullet.GetDmg();
            bullet.Hit();
            if (hp <= 0)
            {
                AudioSource.PlayClipAtPoint(deathSound, transform.position);
                sr        = GetComponent <SpriteRenderer> ();
                sr.sprite = destroyedPlayer;
                dead      = true;
                //Destroy (gameObject);
            }
        }
    }
Exemplo n.º 5
0
    void OnTriggerEnter(Collider collider)
    {
        projectile projectile = collider.gameObject.GetComponent <projectile>();

        if (collider.tag == "cannonBall")
        {
            if (projectile)
            {
                // Debug.Log("Projectile");
                health -= projectile.GetDamage();
                projectile.Hit();
                AudioSource.PlayClipAtPoint(hitSound1, transform.position);
                if (health <= 0)
                {
                    Die();
                }
            }
        }
    }