示例#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;
 }