Ejemplo n.º 1
0
        protected override Vector2 OnUpdateSteeringForce(float elapsedTime, Steerable movingEntity)
        {
            // Not necessary to include the check for facing direction this time
            Vector2 toPursuer = Pursuer.Position - movingEntity.Position;

            //uncomment the following two lines to have Evade only consider pursuers
            //within a 'threat range'
            if (toPursuer.LengthSquared() > ThreatRange * ThreatRange)
            {
                return(Vector2.Zero);
            }

            //the lookahead time is propotional to the distance between the pursuer
            //and the pursuer; and is inversely proportional to the sum of the
            //agents' velocities
            float LookAheadTime = toPursuer.Length() / (movingEntity.MaxSpeed + Pursuer.Speed);

            //now flee away from predicted future position of the pursuer
            return(SteeringHelper.Flee(elapsedTime, movingEntity, Pursuer.Position + Pursuer.Velocity * LookAheadTime));
        }
Ejemplo n.º 2
0
 protected override Vector2 OnUpdateSteeringForce(float elapsedTime, Steerable movingEntity)
 {
     return(SteeringHelper.Flee(elapsedTime, movingEntity, Target));
 }