public override Vector2?CalculateResultingVector()
        {
            var entities = Game1.GetMovingEntitiesInRange(Range, ownEntity);

            currentVector = new Vector2();
            //get vector for every entity
            foreach (BaseEntity entity in entities)
            {
                currentVector += 20 * BehaviourUtil.CalculateSeekVector(ownEntity.Position, entity.Position);
            }
            return(currentVector);
        }
Esempio n. 2
0
        public override Vector2?CalculateResultingVector()
        {
            var entities = Game1.GetMovingEntitiesInRange(Settings.DistancingRange, ownEntity);

            currentVector = new Vector2();
            targets       = new List <Vector2>();

            foreach (BaseEntity entity in entities)
            {
                if (ownEntity.GetType() == entity.GetType())
                {
                    Vector2 target = Vector2.Subtract(ownEntity.Position, entity.GetClosestCoords(ownEntity.Position));
                    target  = Vector2.Normalize(target);
                    target *= (float)Settings.DistancingRange / 2;
                    targets.Add(target);
                    currentVector += BehaviourUtil.CalculateSeekVector(ownEntity.Position, Vector2.Add(target, entity.Position));
                }
            }
            return(currentVector);
        }
 public override Vector2?CalculateResultingVector()
 {
     if (Waypoints != null && Target != null)
     {
         if (currentWaypoint < Waypoints.Length - 1)
         {
             if (UpdateAstar && Vector2.DistanceSquared(Target.Position, Target.GetClosestCoords(Waypoints[Waypoints.Length - 1])) > Game1.Grid.RegionSize * Game1.Grid.RegionSize)
             {
                 GenerateWaypoints();
             }
             UpdateWaypoint();
             if (Waypoints != null)
             {
                 return(Currentvector = BehaviourUtil.CalculateSeekVector(ownEntity.Position, Game1.GetClosestCoords(ownEntity.Position, Waypoints[currentWaypoint])));
             }
             return(null);
         }
         return(Currentvector = BehaviourUtil.CalculateSeekVector(ownEntity.Position, Game1.GetClosestCoords(ownEntity.Position, Target.Position)));
     }
     return(null);
 }
 public override Vector2?CalculateResultingVector()
 {
     Currentvector = BehaviourUtil.CalculateSeekVector(ownEntity.Position, Target.GetClosestCoords(ownEntity.Position)) * -1;
     return(Currentvector);
 }