コード例 #1
0
ファイル: PathFindingGrid.cs プロジェクト: Mongar23/AgileExam
        private void CreateGrid()
        {
            // Make a new two dimensional grid array with the max amount of node fitted in de world size of the grid.
            grid = new Node[gridSize.x, gridSize.y];

            // Get the bottom left of corner of the grid as a world point.
            Vector3 bottomLeft = CachedTransform.position - Vector3.right * gridWorldSize.x * 0.5f - Vector3.up * gridWorldSize.y * 0.5f;

            for (var x = 0; x < gridSize.x; x++)
            {
                for (var y = 0; y < gridSize.y; y++)
                {
                    // Calculate the center of the node in the world position.
                    Vector3 worldPoint = bottomLeft + Vector3.right * (x * nodeDiameter + nodeRadius) + Vector3.up * (y * nodeDiameter + nodeRadius);

                    // Add the node to the grid.
                    grid[x, y] = new Node(IsNodeWalkable(worldPoint), worldPoint, new Vector2Int(x, y));
                }
            }

            GridCreatedEvent?.Invoke();
        }
コード例 #2
0
ファイル: LevelManager.cs プロジェクト: lopezmramon/TeslaGrid
 private void OnGridCreated(GridCreatedEvent e)
 {
     this.grid = e.grid;
     CreateShadow(grid.transform);
 }