Ejemplo n.º 1
0
        public Mountainous(float minNoise) : base(minNoise)
        {
            baseNoiseGen.SetNoiseType(FastNoise.NoiseType.PerlinFractal);
            baseNoiseGen.SetFrequency(0.015f);
            baseNoiseGen.SetFractalOctaves(2);

            layers = new BiomeLayer[1] {
                new Mountains(0)
            };
        }
Ejemplo n.º 2
0
        //public List<List<double>> SumResProbs = new List<List<double>>();
        //public List<double> MaxResProb = new List<double>();

        public BCMBiomeLayer(BiomeLayer layer)
        {
            Block  = new BCMBiomeBlockDecoration(layer.m_Block);
            Depth  = layer.m_Depth;
            FillTo = layer.m_FillUpTo;
            foreach (var p in layer.m_Resources)
            {
                Resources.Add(p.Select(deco => new BCMBiomeBlockDecoration(deco)).ToList());
            }
        }
Ejemplo n.º 3
0
 public FeatureGroup getFeatureGroup(float nutrients, BiomeLayer biomeLayer, Vector2 worldPos)
 {
     foreach (FeatureGroup featureGroup in biomeLayer.featureGroups)
     {
         if (nutrients >= featureGroup.minAllowedNutrients && nutrients <= featureGroup.maxAllowedNutrients)
         {
             return(featureGroup);
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        public HillyFlats(float minNoise) : base(minNoise)
        {
            baseNoiseGen.SetNoiseType(FastNoise.NoiseType.PerlinFractal);
            baseNoiseGen.SetFrequency(0.02f);

            layers = new BiomeLayer[2] {
                new Flats(0),
                new Hills(0.5f)
            };

            InitialiseLayers();
        }
Ejemplo n.º 5
0
    // At the moment it just generates a simple chunk, probably fine performance-wise
    public SimpleChunk GetSimpleChunkAt(Vector2Int chunkPos)     // TODO: Pull from memory and storage
    {
        float[,] chunkHeightMap  = heightGenerator.GenerateHeightMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y));
        float[,] chunkClimateMap = climateGenerator.GenerateClimateNoiseMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y));
        float[,] chunkBiomeMap   = biomeGenerator.GenerateBiomeNoiseMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y));
        float[,] chunkFeatureMap = featureGenerator.GenerateObjectNutrientsMap(1, 1, new Vector2Int(chunkPos.x, chunkPos.y));

        Biome        biome        = biomeGenerator.getBiome(chunkBiomeMap[0, 0], chunkHeightMap[0, 0], chunkClimateMap[0, 0]);
        BiomeLayer   biomeLayer   = biomeGenerator.getBiomeLayer(biome, chunkHeightMap[0, 0], chunkClimateMap[0, 0]);
        FeatureGroup featureGroup = featureGenerator.getFeatureGroup(chunkFeatureMap[0, 0], biomeLayer, Vector2.zero);

        return(new SimpleChunk(biome, biomeLayer));
    }
Ejemplo n.º 6
0
    // Generates the tile textures to be applied to the chunk texture
    void GenerateChunkTileTextures()
    {
        // NEEDS TO CHECK WHETHER THE STORAGE HAS ANYTHING STORED FOR THIS CHUNK
        float[,] chunkHeightMap = world.heightGenerator.GenerateHeightMap(world.chunkSize, world.chunkSize, chunkPos);
        float[,] chunkClimateMap = world.climateGenerator.GenerateClimateNoiseMap(world.chunkSize, world.chunkSize, chunkPos);
        float[,] chunkBiomeMap = world.biomeGenerator.GenerateBiomeNoiseMap(world.chunkSize, world.chunkSize, chunkPos);

        for (int chunkTileY = 0; chunkTileY < world.chunkSize; chunkTileY++)
        {
            for (int chunkTileX = 0; chunkTileX < world.chunkSize; chunkTileX++)
            {
                Biome biome = world.biomeGenerator.getBiome(chunkBiomeMap[chunkTileX, chunkTileY], chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);
                BiomeLayer biomeLayer = world.biomeGenerator.getBiomeLayer(biome, chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);

                chunkBiomeLayers[chunkTileX, chunkTileY] = biomeLayer;

                chunkTileTextures[chunkTileX, chunkTileY] = biomeLayer.groundTile.texture;
            }
        }
    }
Ejemplo n.º 7
0
    // At the moment it just generates the default chunk at the chunk pos (Misses out the features)
    public Chunk GetChunkAt(Vector2Int chunkPos)     // TODO: Pull from memory and storage
    {
        Chunk chunk = new Chunk(this, chunkPos);

        float[,] chunkHeightMap  = heightGenerator.GenerateHeightMap(chunkSize, chunkSize, chunkPos);
        float[,] chunkClimateMap = climateGenerator.GenerateClimateNoiseMap(chunkSize, chunkSize, chunkPos);
        float[,] chunkBiomeMap   = biomeGenerator.GenerateBiomeNoiseMap(chunkSize, chunkSize, chunkPos);

        for (int chunkTileY = 0; chunkTileY < chunkSize; chunkTileY++)
        {
            for (int chunkTileX = 0; chunkTileX < chunkSize; chunkTileX++)
            {
                Biome      biome      = biomeGenerator.getBiome(chunkBiomeMap[chunkTileX, chunkTileY], chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);
                BiomeLayer biomeLayer = biomeGenerator.getBiomeLayer(biome, chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);

                chunk.tiles[chunkTileX, chunkTileY] = biomeLayer.groundTile;
            }
        }

        return(chunk);
    }
    public void Execute()
    {
        OriginalBiomeLayer = new List <BiomeLayer>();
        List <RandomGenerationLayer> OriginalLayer = new List <RandomGenerationLayer>();

        foreach (var layer in generationLayers)
        {
            layer.mapSize = mapSize;
            BiomeLayer tmp = new BiomeLayer();
            tmp.ShowLayer = true;
            tmp.layer     = Instantiate(layer);
            OriginalBiomeLayer.Add(tmp);
        }

        foreach (var layer in OriginalBiomeLayer)
        {
            layer.layer.previousLayerData = OriginalLayer;
            layer.layer.Execute();
            OriginalLayer.Add(layer.layer);
        }
    }
Ejemplo n.º 9
0
    // Generates the chunk colors to be applied to the world texture
    void GenerateWorldChunkColors()
    {
        int worldWidth  = world.width * pixelsPerChunk;
        int worldHeight = world.height * pixelsPerChunk;

        for (chunkY = 0; chunkY < worldHeight; chunkY++)
        {
            for (chunkX = 0; chunkX < worldWidth; chunkX++)
            {
                float[,] chunkHeightMap  = world.heightGenerator.GenerateHeightMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY));
                float[,] chunkClimateMap = world.climateGenerator.GenerateClimateNoiseMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY));
                float[,] chunkBiomeMap   = world.biomeGenerator.GenerateBiomeNoiseMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY));
                float[,] chunkFeatureMap = world.featureGenerator.GenerateObjectNutrientsMap(pixelsPerChunk, pixelsPerChunk, new Vector2Int(chunkX, chunkY));

                for (int chunkTileY = 0; chunkTileY < pixelsPerChunk; chunkTileY++)
                {
                    for (int chunkTileX = 0; chunkTileX < pixelsPerChunk; chunkTileX++)
                    {
                        int x = (chunkX * pixelsPerChunk) + chunkTileX;
                        int y = (chunkY * pixelsPerChunk) + chunkTileY;

                        Biome        biome        = world.biomeGenerator.getBiome(chunkBiomeMap[chunkTileX, chunkTileY], chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);
                        BiomeLayer   biomeLayer   = world.biomeGenerator.getBiomeLayer(biome, chunkHeightMap[chunkTileX, chunkTileY], chunkClimateMap[chunkTileX, chunkTileY]);
                        FeatureGroup featureGroup = world.featureGenerator.getFeatureGroup(chunkFeatureMap[chunkTileX, chunkTileY], biomeLayer, Vector2.zero);

                        if (featureGroup != null)
                        {
                            chunkColors[(y * worldWidth) + x] = featureGroup.mapColor;
                        }
                        else
                        {
                            chunkColors[(y * worldWidth) + x] = biomeLayer.groundTile.mapColor;
                        }
                    }
                }
            }
        }
    }
        protected virtual StatelessGenLayer CreateGenLayers(int seed)
        {
            StatelessGenLayer addIsland0 = new IslandLayer(seed, null);
            StatelessGenLayer zoomed0    = new ZoomLayer(seed, addIsland0);

            StatelessGenLayer biomesAdded = new BiomeLayer(seed, zoomed0);
            StatelessGenLayer addIsland1  = new AddIslandLayer(2, biomesAdded);
            StatelessGenLayer zoomed1     = new ZoomLayer(seed, addIsland1);
            StatelessGenLayer addIsland2  = new AddIslandLayer(50, zoomed1);

            // GenLayer zoomed2 = new GenLayerZoom(seed, zoomed0);
            StatelessGenLayer zoomed2 = ZoomLayer.Magnify(seed, addIsland2, 4);

            StatelessGenLayer addBeach = new AddBeachLayer(50, zoomed2);
            StatelessGenLayer zoomed3  = new ZoomLayer(seed, addBeach);
            StatelessGenLayer addRiver = new AddRiverLayer(1000, zoomed3);

            StatelessGenLayer result = ZoomLayer.Magnify(seed, addRiver, 2);

            // GenLayer biomesAdded = new GenLayerBiome(seed, zoomed0);
            // GenLayer zoomed2 = new GenLayerZoom(seed, zoomed1);
            return(result);
        }
Ejemplo n.º 11
0
 public SimpleChunk(Biome biome, BiomeLayer biomeLayer)
 {
     this.biome      = biome;
     this.biomeLayer = biomeLayer;
 }