Ejemplo n.º 1
0
    public override void TakeHit(float damage, Vector3 hitPoint, Vector3 hitDir)
    {
        AudioManager.instance.PlaySound("Impact", transform.position);

        if (damage >= health)     //if it died, make big particle go whoosh
        {
            ParticleSystem instDeathFX = Instantiate(deathEffect, hitPoint, Quaternion.FromToRotation(Vector3.forward, hitDir)) as ParticleSystem;
            Material       mat         = instDeathFX.GetComponent <Renderer>().material;
            mat.color = originalColour;
            AudioManager.instance.PlaySound("Enemy Death", transform.position);
            Destroy(instDeathFX, 3f);
            DiedAt(transform.position, originalColour);
        }
        else     //if took damage but didnt die, make smol particle go wosh
        {
            ParticleSystem instHitFx = Instantiate(hitEffect, hitPoint, Quaternion.FromToRotation(Vector3.back, hitDir)) as ParticleSystem;
            Material       mat       = instHitFx.GetComponent <Renderer>().material;
            mat.color = originalColour;
            Destroy(instHitFx, 3f);
            //StartCoroutine(Stagger(.5f));
        }

        DamagePopup popupInstance = Instantiate(dmgPopup, hitPoint, Quaternion.AngleAxis(70, Vector3.right)) as DamagePopup;

        popupInstance.Customize(2f, damage, hitPoint);

        base.TakeHit(damage, hitPoint, hitDir);
    }