protected override void OnActivate()
        {
            AIPathPoint aipathPoint = this.GetClosestPathPointInRange(EnemyAISpawnManager.Get().m_MinActivationDistance, EnemyAISpawnManager.Get().m_MaxActivationDistance);

            if (!aipathPoint)
            {
                float num = 0f;
                aipathPoint = this.GetClosestPathPoint(out num);
            }
            Vector3 normalized = (aipathPoint.m_Next.transform.position - aipathPoint.transform.position).normalized;

            foreach (HumanAI humanAI in this.m_Members)
            {
                humanAI.transform.position = aipathPoint.transform.position + UnityEngine.Random.insideUnitSphere * humanAI.m_PatrolModule.m_PathShift;
                humanAI.transform.rotation = Quaternion.LookRotation(normalized, Vector3.up);
                humanAI.m_PatrolModule.m_CurrentPathPoint = aipathPoint.m_Next;
                humanAI.m_PatrolModule.CalcPath();
            }
            if (this.m_Members.Count > 0)
            {
                this.m_Leader = this.m_Members[UnityEngine.Random.Range(0, this.m_Members.Count)];
            }
            else
            {
                this.m_Leader = null;
            }
            base.OnActivate();
        }
Exemple #2
0
        protected override void UpdateActivity()
        {
            if (this.m_ChallengeGroup)
            {
                return;
            }
            float       maxValue         = float.MaxValue;
            AIPathPoint closestPathPoint = this.GetClosestPathPoint(out maxValue);

            if (closestPathPoint && maxValue >= HumanAIGroupManager.Get().m_DeactivationDistance)
            {
                base.Deactivate();
            }
        }
        public AIPathPoint GetClosestPathPointInRange(float min_dist, float max_dist)
        {
            Vector3     position = Player.Get().transform.position;
            AIPathPoint result   = null;
            float       num      = float.MaxValue;

            foreach (AIPathPoint aipathPoint in this.m_Path)
            {
                float num2 = aipathPoint.transform.position.Distance(position);
                if (num2 >= min_dist && num2 <= max_dist && num2 < num)
                {
                    result = aipathPoint;
                    num    = num2;
                }
            }
            return(result);
        }
        public AIPathPoint GetClosestPathPoint(out float distance)
        {
            Vector3     position = Player.Get().transform.position;
            AIPathPoint result   = null;

            distance = float.MaxValue;
            foreach (AIPathPoint aipathPoint in this.m_Path)
            {
                float num = aipathPoint.transform.position.Distance(position);
                if (num < distance)
                {
                    result   = aipathPoint;
                    distance = num;
                }
            }
            return(result);
        }
Exemple #5
0
        private bool CheckPatrol(HumanAIPatrol group)
        {
            if (group.m_Active)
            {
                return(false);
            }
            float       num = 0f;
            AIPathPoint closestPathPoint = group.GetClosestPathPoint(out num);
            bool        flag             = closestPathPoint && num <this.m_MaxActivationDistance && num> this.m_MinActivationDistance;

            if (flag)
            {
                group.Activate();
                return(true);
            }
            return(false);
        }
Exemple #6
0
        protected override void OnActivate()
        {
            base.OnActivate();
            float       maxValue    = float.MaxValue;
            AIPathPoint aipathPoint = this.GetClosestPathPoint(out maxValue);

            for (int i = 0; i < 5; i++)
            {
                aipathPoint = aipathPoint.m_Prev;
            }
            Vector3 normalized = (aipathPoint.m_Next.transform.position - aipathPoint.transform.position).normalized;

            foreach (HumanAI humanAI in this.m_Members)
            {
                humanAI.transform.position = aipathPoint.transform.position + UnityEngine.Random.insideUnitSphere * humanAI.m_PatrolModule.m_PathShift;
                humanAI.transform.rotation = Quaternion.LookRotation(normalized, Vector3.up);
                humanAI.m_PatrolModule.m_CurrentPathPoint = aipathPoint.m_Next;
                humanAI.m_PatrolModule.CalcPath();
            }
            this.m_Leader = this.m_Members[UnityEngine.Random.Range(0, this.m_Members.Count)];
        }