Ejemplo n.º 1
0
    public void Damage(float dmg)
    {
        if (dmg > 0 && health > 0)
        {
            if (!invisible)
            {
                health -= dmg;
                if (au)
                {
                    au.pitch = Random.Range(0.75f, 1.25f);
                }

                if (health <= 0)
                {
                    health = 0;
                    if (mobController)
                    {
                        mobController.Dead();
                    }
                    if (fbc)
                    {
                        fbc.Death();
                    }
                    Death();
                }
                else
                {
                    anim.SetTrigger("Hurt");
                    if (fbc)
                    {
                        fbc.Hurt();
                    }
                    if (mobController)
                    {
                        mobController.Hurt();
                    }
                    if (hurtClips.Count > 0)
                    {
                        au.PlayOneShot(hurtClips[Random.Range(0, hurtClips.Count)]);
                    }
                }

                if (health > 0)
                {
                    StartCoroutine("InvisibleFrames");
                }

                if (player)
                {
                    GameManager.instance.playerController.Hurt(0.75f, "", null);
                    GameManager.instance.gui.SetHealth();
                }
            }
        }
    }