Example #1
0
    public void Initialize(MapCell[,] map, MapCoordinate goalCell)
    {
        _goalCell = goalCell;

        var xDimension = map.GetLength(0);
        var yDimension = map.GetLength(1);

        _grid = new Grid(xDimension, yDimension);
        AdjustInitialCostOfTraversal(map);
    }
Example #2
0
        private Grid CreateGrid(int[,] cave)
        {
            var pathfinder = new RoyT.AStar.Grid(_width, _height);

            for (int x = 0; x < _width; x++)
            {
                for (int y = 0; y < _height; y++)
                {
                    pathfinder.SetCellCost(new RoyT.AStar.Position(x, y), (cave[x, y] + 1) * 10);
                }
            }

            return(pathfinder);
        }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     m_grid = new RoyT.AStar.Grid(40, 25);
     for (int x = -20; x < 19; x++)
     {
         for (int y = -10; y < 14; y++)
         {
             if (map.HasTile(new Vector3Int(x, y, 0)))
             {
                 m_grid.BlockCell(new Position(x + 20, y + 10));
                 //Debug.Log("(" + x + "," + y + ") blocked");
             }
         }
     }
 }
Example #4
0
 public void UnblockCell(Grid grid, Vector2Int position)
 {
     grid.UnblockCell(new Position(position.x + startX, position.y + startY));
 }