Ejemplo n.º 1
0
        private void ProcessLocation(int currentDistance, Entities.Grid grid, Entities.GridLocation startPoint, Entities.GridLocation endPoint)
        {
            var currentPoint = startPoint;

            if (!currentPoint.DistanceFromStart.HasValue ||
                currentPoint.DistanceFromStart.Value > currentDistance)
            {
                currentPoint.DistanceFromStart = currentDistance;

                for (int xDelta = -1; xDelta < 2; xDelta++)
                    for (int yDelta = -1; yDelta < 2; yDelta++)
                    {
                        var newLocation = grid.TraversableLocationAtOffset(currentPoint, xDelta, yDelta);
                        if (newLocation != null)
                            ProcessLocation(currentDistance + 1, grid, newLocation, endPoint);
                    }
            }
        }