Exemplo n.º 1
0
        public EnemyTarget GetEnemy(Vector3 from)
        {
            EnemyTarget r       = null;
            float       minDist = float.MaxValue;

            for (int i = 0; i < enemyTargets.Count; i++)
            {
                float tDist = Vector3.Distance(from, enemyTargets[i].GetTarget().position);
                if (tDist < minDist)
                {
                    minDist = tDist;
                    r       = enemyTargets[i];
                }
            }
            return(r);
        }
Exemplo n.º 2
0
        bool CheckForBackStab(Action slot)
        {
            if (slot.canBackstab == false)
            {
                return(false);
            }
            EnemyStates backstabTarget = null;
            Vector3     origin         = transform.position;

            origin.y += 1;
            Vector3    rayDir = transform.forward;
            RaycastHit hit;

            if (Physics.Raycast(origin, rayDir, out hit, 1, ignoreLayers))
            {
                backstabTarget = hit.transform.GetComponentInParent <EnemyStates>();
            }

            if (backstabTarget == null)
            {
                return(false);
            }

            Vector3 dir = transform.position - backstabTarget.transform.position;

            dir.Normalize();
            dir.y = 0;
            float angle = Vector3.Angle(backstabTarget.transform.forward, dir);

            if (angle > 150)
            {
                Vector3 targetPosition = dir * critAtkOffset;
                targetPosition    += backstabTarget.transform.position;
                transform.position = targetPosition;


                backstabTarget.transform.rotation = transform.rotation;
                backstabTarget.BeingBackstabbed(slot);
                canMove  = false;
                inAction = true;
                anim.SetBool(StaticStrings.mirror, slot.mirror);
                anim.Play(StaticStrings.parry_attack);
                lockOnTarget = null;
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        void Start()
        {
            health      = characterStats.hp;
            anim        = GetComponentInChildren <Animator>();
            enemyTarget = GetComponent <EnemyTarget>();
            enemyTarget.Init(this);

            rigid = GetComponent <Rigidbody>();

            a_hook = anim.GetComponent <AnimatorHook>();
            if (a_hook == null)
            {
                a_hook = anim.gameObject.AddComponent <AnimatorHook>();
            }
            a_hook.Init(null, this);

            InitRagdoll();
            parryable = false;
        }
Exemplo n.º 4
0
        bool CheckForParry(Action slot)
        {
            if (slot.canRiposte == false)
            {
                return(false);
            }

            EnemyStates parryTarget = null;
            Vector3     origin      = transform.position;

            origin.y += 1;
            Vector3    rayDir = transform.forward;
            RaycastHit hit;

            if (Physics.Raycast(origin, rayDir, out hit, 3, ignoreLayers))
            {
                parryTarget = hit.transform.GetComponentInParent <EnemyStates>();
            }

            if (parryTarget == null)
            {
                return(false);
            }

            if (parryTarget.parriedBy == null)
            {
                return(false);
            }

            // float dis = Vector3.Distance(parryTarget.transform.position, transform.position);

            // if( dis > 3) {
            //     return false;
            // }

            Vector3 dir = parryTarget.transform.position - transform.position;

            dir.Normalize();
            dir.y = 0;
            float angle = Vector3.Angle(transform.forward, dir);

            if (angle < 60)
            {
                Vector3 targetPosition = -dir * critAtkOffset;
                targetPosition    += parryTarget.transform.position;
                transform.position = targetPosition;

                if (dir == Vector3.zero)
                {
                    dir = -parryTarget.transform.forward;
                }
                Quaternion eRotation = Quaternion.LookRotation(-dir);
                Quaternion playerRot = Quaternion.LookRotation(dir);

                parryTarget.transform.rotation = eRotation;
                transform.rotation             = playerRot;
                parryTarget.BeingRiposted(slot);
                canMove  = false;
                inAction = true;
                anim.SetBool(StaticStrings.mirror, slot.mirror);
                anim.Play(StaticStrings.parry_attack);
                lockOnTarget = null;
                return(true);
            }
            return(false);
        }