Esempio n. 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);
            }
        public ThreeTieredCaveGenerator(MeshGenerator meshGenerator, ThreeTierCaveConfiguration configuration)
        {
            if (meshGenerator == null)
            {
                throw new ArgumentNullException("meshGenerator");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            string message = configuration.Validate();

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

            this.meshGenerator = meshGenerator;
            this.configuration = configuration;
        }