Ejemplo n.º 1
0
        private string GetOreAt(int worldX, int worldY, Biome biome, string baseBlock)
        {
            Block block = world.resources.GetBlock(baseBlock);

            if (!block.solid)
            {
                return(baseBlock);                          //Only allow ore on solid terrain blocks
            }
            foreach (string oreName in biome.ores)
            {
                Ore   ore      = world.resources.GetOre(oreName);
                float oreNoise = world.generate.Ore(worldX, worldY, oreName, ore.scale);
                if (oreNoise > ore.cutoff)
                {
                    return(oreName);
                }
            }

            return(baseBlock);
        }
Ejemplo n.º 2
0
        private void Generate()
        {
            colors = new Color[WIDTH][];

            int seed = random.Next();

            world = new World("BiomeTest", seed, resources);

            for (int x = 0; x < WIDTH; x++)
            {
                colors[x] = new Color[HEIGHT];
                for (int y = START_Y; y < END_Y; y++)
                {
                    Biome biome = world.GetBiomeAt(x, y);
                    Tuple <float, float> values = world.generate.Terrain(x, y, biome.minHeight, biome.maxHeight);
                    float value = values.Item2;
                    value = value < -0.5f ? (values.Item1 < -0.4f ? 0.1f : 0.25f) : value < -0.4f ? 0.8f : 1;
                    if (y < World.SEA_LEVEL)
                    {
                        value /= 2;
                    }

                    int[] c     = biome.color;
                    Color color = new Color((int)(c[0] * value), (int)(c[1] * value), (int)(c[2] * value));

                    if (values.Item2 > -0.5)
                    {
                        foreach (string oreName in biome.ores)
                        {
                            Ore ore = resources.GetOre(oreName);
                            if (world.generate.Ore(x, y, oreName, ore.scale) > ore.cutoff)
                            {
                                color = new Color((uint)oreName.GetHashCode());
                            }
                        }
                    }

                    colors[x][y - START_Y] = color;
                }
            }
        }