public override GameObject Generate()
        {
            int           scale            = configuration.Scale;
            Map           map              = configuration.MapGenerator.Generate();
            Material      floorMaterial    = configuration.Material;
            IHeightMap    heightMap        = configuration.HeightMapModule.GetHeightMap();
            OutlineModule outlinePrefabber = configuration.OutlineModule;

            GameObject cave = new GameObject("Cave");

            Map[,] mapChunks = MapSplitter.Subdivide(map);
            mapChunks.ForEach((x, y) =>
            {
                Coord index = new Coord(x, y);

                WallGrid grid             = MapConverter.MapToWallGrid(mapChunks[x, y], scale, index);
                List <Vector3[]> outlines = meshGenerator.BuildOutlines(grid);
                CaveMeshes caveMeshes     = BuildCaveMesh(grid, heightMap);
                Sector sector             = BuildSector(caveMeshes, index, cave, floorMaterial);
                GameObject rockAnchor     = BuildRockAnchor(sector.GameObject, index);
                BuildOutline(outlines, outlinePrefabber, rockAnchor.transform);
            });

            return(cave);
        }
예제 #2
0
            public GameObject Generate(RockCaveConfiguration config, bool randomizeSeeds)
            {
                if (config == null)
                {
                    throw new ArgumentNullException("config");
                }

                string message = config.Validate();

                if (message.Length > 0)
                {
                    throw new ArgumentException(message, "config");
                }

                if (randomizeSeeds)
                {
                    config.SetSeed(GetRandomSeed());
                }

                int               scale            = config.Scale;
                Map               map              = config.MapGenerator.Generate();
                Material          floorMaterial    = config.Material;
                IHeightMap        heightMap        = config.HeightMapModule.GetHeightMap();
                IOutlinePrefabber outlinePrefabber = config.OutlineModule.GetOutlinePrefabber();

                GameObject cave = new GameObject("Cave");

                Map[,] mapChunks = MapSplitter.Subdivide(map);
                mapChunks.ForEach((x, y) =>
                {
                    Coord index = new Coord(x, y);

                    WallGrid grid             = MapConverter.MapToWallGrid(mapChunks[x, y], scale, index);
                    List <Vector3[]> outlines = MeshGenerator.BuildOutlines(grid);
                    CaveMeshes caveMeshes     = BuildCaveMesh(grid, heightMap);
                    Sector sector             = BuildSector(caveMeshes, index, cave, floorMaterial);
                    GameObject rockAnchor     = BuildRockAnchor(sector.GameObject, index);
                    PlaceRocks(outlines, outlinePrefabber, rockAnchor.transform);
                });

                return(cave);
            }