Example #1
0
 private static void TryAddPosition(InternalMap map, Direction direction, InternalPoint position, int xOffset, int yOffset)
 {
     var availableDirections = map.AvailableDirectionsByCoordinates[position.X, position.Y];
     var point = new InternalPoint(position.X + xOffset, position.Y + yOffset, direction);
     if ( (availableDirections & direction)!= 0 && !handled.Contains(point))
     {
         AddPoint(point);
         parents.SafeAdd(point, position);
     }
 }
Example #2
0
 public static Direction[] FindPath(InternalMap map, Point from, Point to)
 {
     var lastDirection = Bfs(map, from, to);
     var directions = new List<Direction>();
     var currentPoint = new InternalPoint(to.X, to.Y, lastDirection);
     while (parents.ContainsKey(currentPoint))
     {
         directions.Add(currentPoint.Direction);
         currentPoint = parents[currentPoint];
     }
     directions.Reverse();
     return directions.ToArray();
 }
Example #3
0
 private static void AddPoint(InternalPoint point)
 {
     queue.Enqueue(point);
     handled.Add(point);
 }
Example #4
0
 protected bool Equals(InternalPoint other)
 {
     return X == other.X && Y == other.Y;
 }