Esempio n. 1
0
    public Position[] GetPath(Position start, Position end)
    {
        //
        if (!this.initialized)
        {
            this.Initialize();
        }

        var cb = ground.cellBounds;

        Position[] path = grid.GetPath(
            new Position(
                start.X - cb.xMin,
                start.Y - cb.yMin),
            new Position(
                end.X - cb.xMin,
                end.Y - cb.yMin),
            MovementPatterns.LateralOnly);

        Position[] adjustedPath = new Position[path.Length];
        for (int i = 0; i < path.Length; i++)
        {
            adjustedPath[i] = new Position(
                path[i].X + cb.xMin,
                path[i].Y + cb.yMin);
        }

        return(adjustedPath);
    }
Esempio n. 2
0
 public Vector3[] CalculatePath(Vector3 startPoint, Vector3 endPoint)
 {
     Position[] path      = m_grid.GetPath(new Position((int)(startPoint.x - 0.5f) + 20, (int)(startPoint.y - 0.5f) + 10), new Position((int)(endPoint.x - 0.5f) + 20, (int)(endPoint.y - 0.5f) + 10));
     Vector3[]  positions = new Vector3[path.Length];
     for (int i = 0; i < path.Length; i++)
     {
         positions[i] = new Vector3(path[i].X - 19.5f, path[i].Y - 9.5f, 0);
     }
     return(positions);
 }
Esempio n. 3
0
 private MapCoordinate[] FindPath(MapCoordinate currentLocation)
 {
     return(_grid.GetPath(currentLocation.ToPosition(), _goalCell.ToPosition(), MovementPatterns.LateralOnly)
            .Select(position => position.ToMapCoordinate()).ToArray());
 }