예제 #1
0
        private void AddPath(LevelTile[,] tiles)
        {
            TilePosition?previousPosition = null;

            foreach (var position in _path)
            {
                tiles[position.X, position.Y] = LevelTile.Room();

                if (previousPosition.HasValue)
                {
                    LevelTileConnector.Connect(tiles, previousPosition.Value, position);
                }

                previousPosition = position;
            }
        }
        private void GenerateCorridor(LevelTile[,] tiles, TilePosition origin)
        {
            for (var depth = 0; depth < _maxDepth; depth++)
            {
                var neighbor = GetRandomNeighbor(origin);
                var width    = tiles.GetWidth();
                var height   = tiles.GetHeight();
                if (!IsInsideBounds(neighbor, width, height))
                {
                    return;
                }
                if (tiles[neighbor.X, neighbor.Y].Type != LevelTileType.None)
                {
                    return;
                }

                tiles[neighbor.X, neighbor.Y] = LevelTile.Room();
                LevelTileConnector.Connect(tiles, origin, neighbor);
                origin = neighbor;
            }
        }