Exemplo n.º 1
0
    public void applyDamage(float damage)
    {
        barProgress -= damage;

        if (hurtClip != null && damage > 0)
        {
            AudioSource.PlayClipAtPoint(hurtClip, Camera.main.transform.position, hurtVolume);
        }

        // Kill the game obj if it loses all its health
        if (barProgress <= 0)
        {
            Destroy(bar.gameObject);
            Destroy(this);

            if (isPlayer)
            {
                Destroy(gameObject);
            }
            else
            {
                Enemy1 e = gameObject.GetComponent <Enemy1>();
                e.IAmDead();
            }
        }
    }