Example #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);
            }
 void AssignMaterials(ThreeTierCave cave, Material floorMat, Material wallMat, Material ceilingMat)
 {
     foreach (var floor in cave.GetFloors())
     {
         floor.Material = floorMat;
     }
     foreach (var wall in cave.GetWalls())
     {
         wall.Material = wallMat;
     }
     foreach (var ceiling in cave.GetCeilings())
     {
         ceiling.Material = ceilingMat;
     }
 }
        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);
        }