コード例 #1
0
            public GameObject Generate(ThreeTierCaveConfiguration 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());
                }

                Map        map     = config.MapGenerator.Generate();
                IHeightMap floor   = config.FloorHeightMapModule.GetHeightMap();
                IHeightMap ceiling = config.CeilingHeightMapModule.GetHeightMap();

                Map[,] mapChunks         = MapSplitter.Subdivide(map);
                CaveMeshes[,] caveChunks = GenerateCaveChunks(mapChunks, config.CaveType, config.Scale, floor, ceiling);
                ThreeTierCave cave = new ThreeTierCave(caveChunks);

                AssignMaterials(cave, config.FloorMaterial, config.WallMaterial, config.CeilingMaterial);

                return(cave.GameObject);
            }
コード例 #2
0
        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);
        }
コード例 #3
0
        public override GameObject Generate()
        {
            Map            map       = configuration.MapGenerator.Generate();
            IHeightMap     floor     = configuration.FloorHeightMapModule.GetHeightMap();
            IHeightMap     ceiling   = configuration.CeilingHeightMapModule.GetHeightMap();
            CaveWallModule caveWalls = configuration.WallModule;

            Map[,] mapChunks         = MapSplitter.Subdivide(map);
            CaveMeshes[,] caveChunks = GenerateCaveChunks(mapChunks, configuration.CaveType, configuration.Scale, floor, ceiling, caveWalls);
            ThreeTierCave cave = new ThreeTierCave(caveChunks);

            AssignMaterials(cave, configuration.FloorMaterial, configuration.WallMaterial, configuration.CeilingMaterial);

            return(cave.GameObject);
        }
コード例 #4
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);
            }