コード例 #1
0
    private void RemoveUnreachableNodes()
    {
        for (int y = 0; y < mapSize; y++)
        {
            for (int x = 0; x < mapSize; x++)
            {
                int[,] neighbours = GridMath.GetNeighbours(_mapGrid, new Vector2Int(x, y), 0);

                if (GridMath.CheckSurroundedCardinal(neighbours, 0))
                {
                    _mapGrid[y, x] = 0;
                }
            }
        }
    }
コード例 #2
0
 private void WallsFillSurrounded(Room room, int[,] collideGrid)
 {
     for (int y = 0; y < room.Height; y++)
     {
         for (int x = 0; x < room.Width; x++)
         {
             if (collideGrid[y, x] == 0)
             {
                 Vector2Int loc = new Vector2Int(x, y);
                 int[,] neighbours = GridMath.GetNeighbours(collideGrid, loc);
                 if (GridMath.CheckSurroundedCardinal(neighbours, 2))
                 {
                     collideGrid[y, x] = 2;
                 }
             }
         }
     }
 }