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); }
protected virtual void Awake() { GetAllComponets(); SetupDamageableLimbs(); RandomizeAnimator(); SetAllSensorOwner(); currentInterest = null; patrolPointsProvider = FindObjectOfType <PatrolPointsProvider>(); }
public void RemoveCurrentInterestFromSensors() { for (int n = 0; n < sensors.Length; n++) { if (sensors[n].InterestList.Contains(currentInterest)) { sensors[n].InterestList.Remove(currentInterest); } } currentInterest = null; }
protected virtual void UpdateCurrentInterest() { if (!CurrentInterestIsValid() || InterestIsDead(currentInterest) || (CurrentInterestIsValid() && !currentInterest.inRange)) { currentInterest = null; } for (int n = 0; n < sensors.Length; n++) { ProcessSensor(sensors[n]); } }
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]; } } } }
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); }
private float CalculateLastKnowSquareDistanceToInterest(AI_Interest interest) { return((interest.lastKnowPosition - transform.position).magnitude); }
private float CalculateLastKnowDistanceToInterest(AI_Interest interest) { return(Vector3.Distance(interest.lastKnowPosition, transform.position)); }
private bool InterestIsValid(AI_Interest interest) { return(interest != null && interest.stimulation != null); }
private bool InterestIsDead(AI_Interest interest) { return(interest != null && interest.stimulation.VisualType == VisualType.DeadBody); }
public void SetCurrentInterest(AI_Interest interest) { currentInterest = interest; }