Exemple #1
0
 ChartStatic CarveEntrancesIntoChart(RawChart chart, Maze maze, Coord coord)
 {
     IEnumerable<MapEntrance> entrances = GetEntrances(maze, coord);
     chart.Seed = seed;
     var staticModule = MapGenStaticMap.Construct(chart.Map);
     var carvedModule = MapGenEntranceCarver.Construct(staticModule, entrances);
     return ChartStatic.ReplaceMap(carvedModule.Generate(seed), chart);
 }
Exemple #2
0
        /// <summary>
        /// Replaces the map in the chart, creating a new static chart with the same markers and metadata as the original.
        /// Note that the copy may be shallow.
        /// </summary>
        public static ChartStatic ReplaceMap(Map map, RawChart chart)
        {
            ChartStatic newChart = Construct(map);

            newChart.name     = chart.name;
            newChart.markers  = chart.Markers.ToList();
            newChart.metaData = chart.MetaData;
            return(newChart);
        }
Exemple #3
0
        public override Dictionary <Coord, RawChart> GetCharts(Maze maze)
        {
            ValidateCharts();
            random = new System.Random(seed);
            Coord[] cells         = maze.GetCells();
            var     chartsByCoord = new Dictionary <Coord, RawChart>();

            for (int i = 0; i < cells.Length; i++)
            {
                Coord         cell            = cells[i];
                ChartStatic[] candidateCharts = DetermineChartCandidates(maze, cell);
                RawChart      chart           = candidateCharts[random.Next(0, candidateCharts.Length)];
                ChartStatic   carvedChart     = CarveEntrancesIntoChart(chart, maze, cell);
                chartsByCoord[cell] = carvedChart;
            }
            return(chartsByCoord);
        }
Exemple #4
0
        public Chart(RawChart chart, Coord offset)
        {
            if (chart == null)
            {
                throw new ArgumentNullException("chart");
            }

            if (chart.Map == null)
            {
                throw new ArgumentException("Chart has invalid (null) map");
            }

            map         = chart.Map;
            name        = chart.name;
            markers     = chart.Markers.Select(m => new Marker(m, offset)).ToArray();
            this.offset = offset;
            metaData    = chart.MetaData.Unpack();
        }