Пример #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);
        }
Пример #2
0
        bool CheckForBackStab(Action slot)
        {
            if (slot.canBackstab == false)
            {
                return(false);
            }

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

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

            if (Physics.Raycast(origin, rayDirection, out hit, 1, ignoreLayers))
            {
                backstab = hit.transform.GetComponentInParent <EnemyStates>();
            }
            if (backstab == null)
            {
                return(false);
            }

            Vector3 direction = transform.position - backstab.transform.position;

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

            if (angle > 150)
            {
                Vector3 targetPosition = direction * backStabOffset;
                targetPosition    += backstab.transform.position;
                transform.position = targetPosition;

                transform.rotation = transform.rotation;
                backstab.IsGettingBackstabbed(slot, inventoryManager.GetCurrentWeapon(slot.mirror));
                onEmpty  = false;
                canMove  = false;
                inAction = true;
                anim.SetBool(StaticStrings.mirror, slot.mirror);
                anim.CrossFade(StaticStrings.parry_attack, 0.2f);
                lockOnTarget = null;
                return(true);
            }
            return(false);
        }
Пример #3
0
        public void Init()
        {
            anim     = GetComponentInChildren <Animator>();
            enTarget = GetComponent <EnemyTarget>();
            enTarget.Init(this);

            rigid             = GetComponent <Rigidbody>();
            navAgent          = this.GetComponent <NavMeshAgent>();
            rigid.isKinematic = true;



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

            InitRagdoll();
            parryIsOn    = false;
            ignoreLayers = ~(1 << 9);
        }
Пример #4
0
        bool CheckForParry(Action slot)
        {
            //  if (slot.canParry == false)
            //    return false;

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

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

            if (Physics.Raycast(origin, rayDirection, 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 * parryOffset;
                targetPosition    += parryTarget.transform.position;
                transform.position = targetPosition;

                if (dir == Vector3.zero)
                {
                    dir = -parryTarget.transform.forward;
                }

                Quaternion eRotation = Quaternion.LookRotation(-dir);
                Quaternion ourRot    = Quaternion.LookRotation(dir);

                parryTarget.transform.rotation = eRotation;
                transform.rotation             = ourRot;


                parryTarget.IsGettingParried(slot, inventoryManager.GetCurrentWeapon(slot.mirror));
                canAttack = false;
                onEmpty   = false;
                canMove   = false;
                inAction  = true;
                anim.SetBool(StaticStrings.mirror, slot.mirror);
                anim.CrossFade(StaticStrings.parry_attack, 0.2f);
                lockOnTarget = null;
                return(true);
            }

            return(false);
        }