Esempio n. 1
0
 public void CreatePathfindingGrid(StageGrid grid)
 {
     _pathfinding = new AStarGridPathfinding();
     _aStarNodes  = new AStarGridPathfinding.Node[grid.SizeX, grid.SizeY];
     for (var x = 0; x < _aStarNodes.GetLength(0); x++)
     {
         for (var y = 0; y < _aStarNodes.GetLength(1); y++)
         {
             _aStarNodes[x, y] = new AStarGridPathfinding.Node(x, y, grid[x, y]);
         }
     }
 }
Esempio n. 2
0
        public IEnumerator CreateStage(int sizeX, int sizeY)
        {
            // 矩形のグリッドを生成してついでにタイルも生成
            _stageGrid = new StageGrid(sizeX, sizeY);
            foreach (var cell in _stageGrid)
            {
                cell.CreateTile(_tilePrefab, transform);
                yield return(null);
            }

            // お試しで壁を適当に生成
            SpawnWall(GetCell(new Vector2Int(1, 3)));
            SpawnWall(GetCell(new Vector2Int(2, 3)));
            SpawnWall(GetCell(new Vector2Int(3, 2)));
            SpawnWall(GetCell(new Vector2Int(3, 1)));
            SpawnWall(GetCell(new Vector2Int(3, 0)));
            SpawnWall(GetCell(new Vector2Int(3, 3)));
            SpawnWall(GetCell(new Vector2Int(5, 4)));

            // 経路探索用ノード配列生成
            _pathfinding.CreatePathfindingGrid(_stageGrid);
        }