Exemplo 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;
        }
Exemplo n.º 3
0
 public CaveGenerator BuildThreeTierCaveGen(ThreeTierCaveConfiguration config)
 {
     return(new ThreeTieredCaveGenerator(meshGenerator, config));
 }
Exemplo n.º 4
0
 void Reset()
 {
     threeTierCaveConfig = new ThreeTierCaveConfiguration();
     rockCaveConfig      = new RockCaveConfiguration();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Generates a three tiered cave.
        /// </summary>
        /// <param name="randomizeSeeds">Will reroll the random seeds on each randomizable component.</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public static GameObject GenerateThreeTierCave(ThreeTierCaveConfiguration config, bool randomizeSeeds)
        {
            var generator = new ThreeTieredCaveGenerator();

            return(generator.Generate(config, randomizeSeeds));
        }