Exemple #1
0
        } //Constructor

        public override MapGenerator.MapData Generate(MapGenerator.RoomsDataCollection rooms, int mapWidth, int mapHeight)
        {
            // Make sure there are rooms and there is map data, if not then ... return failure.
            if (rooms == null || rooms.Count == 0 || mapWidth <= 0 || mapHeight <= 0)
            {
                return(null);
            }

            // Resize the map to what we need.
            MapGenerator.MapData results = new MapGenerator.MapData(mapWidth, mapHeight);

            // Create the instance to the randomizer.
            MapHelpers.SetRandomSeed(this.Options.Seed);

            // (Step 1) Place the initial rooms to start out with.
            MapHelpers.PlotRandomRooms(results, rooms, MapHelpers.ComputeRandomRoomsCount(mapWidth, mapHeight, this.Options.RandomRoomsPercentage), this.Options.IgnoreBoundries, this.Options.SubsetID, this.Options.IncludeRooms, !this.Options.IncludeRooms, this.Options.Pattern, true);

            // (Step 2) Create the passages to connect each room together.
            MapHelpers.ConnectPathsets(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID);

            // (Step 3) if(there is any left over path sets, remove them.
            //MapHelpers.RemoveAllSmallPathSets(results)

            // Remove the map data.
            return(results);
        } //Generate
        } //Constructor

        public override MapGenerator.MapData Generate(MapGenerator.RoomsDataCollection rooms, int mapWidth, int mapHeight)
        {
            // Make sure there is rooms and map data, if not then ... exit.
            if (rooms == null || rooms.Count == 0 || mapWidth <= 0 || mapHeight <= 0)
            {
                return(null);
            }

            // Clear and resize the map.
            MapGenerator.MapData results = new MapGenerator.MapData(mapWidth, mapHeight);

            // Create the instance to the randomizer.
            MapHelpers.SetRandomSeed(this.Options.Seed);

            // (Step 1) Fill the map with random matching tiles.
            FillWithRandomTiles(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID, this.Options.IncludeRooms, this.Options.IncludePassages, this.Options.Pattern);

            // (Step 2) Decide what to do with the unconnected tiles ...
            if (this.Options.UnconnectedTilesAction == UnconnectedTilesActions.ConnectAll)
            {
                // ... Connect all unconnected tiles.
                MapHelpers.ConnectPathsets(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID);
            }
            else if (this.Options.UnconnectedTilesAction == UnconnectedTilesActions.RemoveSmallerSets)
            {
                // ... Remove all unconnected tiles.
                MapHelpers.RemoveAllSmallPathSets(results);
            }

            // Remove the map data.
            return(results);
        } //Generate