コード例 #1
0
        protected virtual bool CanEngage(AI_Interest interest)
        {
            if (CurrentInterestIsValid() && currentInterest.stimulation == interest.stimulation)
            {
                return(true);
            }

            if (interest.isAttackingMe)
            {
                return(true);
            }

            if (behaviour == Behaviour.Neutral && CurrentInterestIsValid() && currentInterest.isAttackingMe && interest.stimulation == currentInterest.stimulation)
            {
                return(true);
            }

            //flee behaivour never start a engage
            if (behaviour == Behaviour.Neutral)
            {
                return(false);
            }
            //aggresive attack all
            if (behaviour == Behaviour.Aggresive)
            {
                return(true);
            }
            if (behaviour == Behaviour.Normal && interest.stimulation.VisualType != thisStimulation.VisualType)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        protected virtual void Awake()
        {
            GetAllComponets();
            SetupDamageableLimbs();
            RandomizeAnimator();
            SetAllSensorOwner();

            currentInterest      = null;
            patrolPointsProvider = FindObjectOfType <PatrolPointsProvider>();
        }
コード例 #3
0
        public void RemoveCurrentInterestFromSensors()
        {
            for (int n = 0; n < sensors.Length; n++)
            {
                if (sensors[n].InterestList.Contains(currentInterest))
                {
                    sensors[n].InterestList.Remove(currentInterest);
                }
            }

            currentInterest = null;
        }
コード例 #4
0
        protected virtual void UpdateCurrentInterest()
        {
            if (!CurrentInterestIsValid() || InterestIsDead(currentInterest) || (CurrentInterestIsValid() && !currentInterest.inRange))
            {
                currentInterest = null;
            }

            for (int n = 0; n < sensors.Length; n++)
            {
                ProcessSensor(sensors[n]);
            }
        }
コード例 #5
0
 private void ProcessSensor(AISensor sensor)
 {
     for (int n = 0; n < sensor.InterestList.Count; n++)
     {
         //we are no interested in things that we can no see or hear
         if (sensor.InterestList[n].inRange)
         {
             if (ShouldUpdateCurrentInterest(sensor.InterestList[n]))
             {
                 currentInterest = sensor.InterestList[n];
             }
         }
     }
 }
コード例 #6
0
        protected bool ShouldUpdateCurrentInterest(AI_Interest interest)
        {
            //the new interest is no valid
            if (!InterestIsValid(interest) || InterestIsDead(interest) || !CanEngage(interest))
            {
                return(false);
            }

            //if we dont have a interest
            if (!HaveInterest())
            {
                return(true);
            }

            //if the current interest is no the player and the new one is the player
            if (currentInterest.stimulation.VisualType != VisualType.Player && interest.stimulation.VisualType == VisualType.Player)
            {
                return(true);
            }

            //if the current interest is the player and the new one no
            if (currentInterest.stimulation.VisualType == VisualType.Player && interest.stimulation.VisualType != VisualType.Player)
            {
                return(false);
            }

            /*
             * float distanceToCurrentInterest = CalculateLastKnowSquareDistanceToInterest( currentInterest );
             * float distanceToNewInterest = CalculateLastKnowSquareDistanceToInterest( interest );
             *
             * float distanceDiff = Mathf.Abs( distanceToCurrentInterest - distanceToNewInterest );
             *
             * if (distanceDiff > 0.25f * 0.25f && distanceToNewInterest < distanceToCurrentInterest)
             * {
             *  return true;
             * }*/

            return(currentInterest.inRangeAmount + 0.15f < interest.inRangeAmount);
        }
コード例 #7
0
 private float CalculateLastKnowSquareDistanceToInterest(AI_Interest interest)
 {
     return((interest.lastKnowPosition - transform.position).magnitude);
 }
コード例 #8
0
 private float CalculateLastKnowDistanceToInterest(AI_Interest interest)
 {
     return(Vector3.Distance(interest.lastKnowPosition, transform.position));
 }
コード例 #9
0
 private bool InterestIsValid(AI_Interest interest)
 {
     return(interest != null && interest.stimulation != null);
 }
コード例 #10
0
 private bool InterestIsDead(AI_Interest interest)
 {
     return(interest != null && interest.stimulation.VisualType == VisualType.DeadBody);
 }
コード例 #11
0
 public void SetCurrentInterest(AI_Interest interest)
 {
     currentInterest = interest;
 }