Ejemplo n.º 1
0
    public void OnDeath(Vector3 normal)
    {
        PlayVocal(VocalType.Death);
        MyAI.OnDeath();
        Stealth.OnDeath();
        float posture = UnityEngine.Random.Range(0.1f, 200) / 200f;

        int direction = 1;

        if (normal != Vector3.zero)
        {
            normal = new Vector3(normal.x, 0, normal.z);

            float angleRight   = Vector3.Angle(normal, transform.right);
            float angleForward = Vector3.Angle(normal, transform.forward);


            if (angleRight < 60)
            {
                direction = 3;
            }
            else if (angleRight > 120)
            {
                direction = 2;
            }
            else
            {
                if (UnityEngine.Random.value > 0.5f)
                {
                    direction = 0;
                }
                else
                {
                    direction = 1;
                }
            }
        }

        this.MyAnimator.SetInteger("DeathDirection", direction);
        this.MyAnimator.SetFloat("Blend", posture);
        this.MyAnimator.SetBool("IsDead", true);

        CurrentAnimState = new MutantAnimStateDeath(this);
        IsBodyLocked     = true;
        MyAimIK.solver.SmoothDisable(9);
        MyLeftHandIK.SmoothDisable(12);
        MyHeadIK.SmoothDisable(9);
        MyNavAgent.enabled = false;
        MyReference.LiveCollider.enabled           = false;
        MyReference.DeathCollider.enabled          = true;
        MyReference.DeathCollider.gameObject.layer = 18;

        /*
         * CapsuleCollider collider = GetComponent<CapsuleCollider>();
         * collider.height = 0.5f;
         * collider.radius = 0.6f;
         * collider.center = new Vector3(0, 0, 0);
         * collider.isTrigger = true;
         */

        Unhook();
    }