private void SendSquadQuery(GameState s, RTSSquad squad, GameInputEvent e)
 {
     squad.RecalculateGridPosition();
     Vector2 start = squad.GridPosition;
     var swe = e as SetWayPointEvent;
     var ste = e as SetTargetEvent;
     Vector2 goal = start;
     if(swe != null)
         goal = swe.Waypoint;
     else if(ste != null && ste.Target != null)
         goal = ste.Target.GridPosition;
     float minDistSq = float.MaxValue;
     for(int u = 0; u < squad.Units.Count; u++) {
         RTSUnit unit = squad.Units[u];
         float distSq = (goal - unit.GridPosition).LengthSquared();
         if(distSq < minDistSq) {
             minDistSq = distSq;
             start = unit.GridPosition;
         }
     }
     var query = pathfinder.ReissuePathQuery(new PathQuery(start, goal, e.Team), start, goal, e.Team);
     squadQueries.Add(new SquadQuery(squad, query));
 }
Exemplo n.º 2
0
 // Adds Event To Concurrent Queue
 public void AddEvent(GameInputEvent e)
 {
     eventQueue.Enqueue(e);
 }