Ejemplo n.º 1
0
        private static void GenerateOres(World world, TextureAtlas textureAtlas, int x, int y, int stoneY, int seed)
        {
            for (int i = y + stoneY - 7; i < 4 + y + stoneY + 1; i++)
            {
                Random rand1 = new Random(seed + x + y + stoneY + i);
                Random rand2 = new Random(seed + x + y + stoneY + i + 1);

                if (rand1.Next(16) == 0)
                {
                    int oreLength = rand2.Next(2, 6);
                    for (int i_ = x; i_ <= x + oreLength; i_++)
                    {
                        Blocks.CoalOre coalore_ = new Blocks.CoalOre(textureAtlas);
                        world.SetBlockWithReplace(new Vector2(i_, 16 - i + 10), coalore_);
                    }
                }

                Random rand3 = new Random(seed + x + y + stoneY + i + 2);
                Random rand4 = new Random(seed + x + y + stoneY + i + 3);

                if (rand3.Next(28) == 0)
                {
                    int oreLength = rand4.Next(3, 6);
                    for (int i_ = x; i_ <= x + oreLength; i_++)
                    {
                        Blocks.IronOre ironore_ = new Blocks.IronOre(textureAtlas);
                        world.SetBlockWithReplace(new Vector2(i_, 16 - i + 12), ironore_);
                    }
                }

                Random rand5 = new Random(seed + x + y + stoneY + i + 4);
                Random rand6 = new Random(seed + x + y + stoneY + i + 5);

                if (rand5.Next(40) == 0)
                {
                    int oreLength = rand6.Next(2, 5);
                    for (int i_ = x; i_ <= x + oreLength; i_++)
                    {
                        Blocks.GoldOre goldore_ = new Blocks.GoldOre(textureAtlas);
                        world.SetBlockWithReplace(new Vector2(i_, 16 - i + 16), goldore_);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Generate(Mine2D game, TextureAtlas textureAtlas, World world, int seed)
        {
            LibNoise.Perlin noise = new LibNoise.Perlin();
            noise.Seed = seed;

            List<int> maxTreesY = new List<int>();
            for (int x = -256; x < 256; x++)
            {
                double Y = noise.GetValue((float)x / 17F, 1, 1) * 4;
                int y = (int)Y;
                maxTreesY.Add(16 - y - 16);
                Blocks.Grass grass = new Blocks.Grass(textureAtlas);
                world.SetBlock(new Vector2(x, 16 - y), grass);

                int dirtY = new Random(seed + x + y).Next(2, 5);
                int stoneY = y - new Random(seed + x + y + 1).Next(5, 8) + (3 - dirtY);
                for (int i = y - dirtY; i < y; i++)
                {
                    Blocks.Dirt dirt_ = new Blocks.Dirt(textureAtlas);
                    world.SetBlock(new Vector2(x, 16 - i), dirt_);
                }
                for (int i = -24; i < 4 + y + (4 - dirtY) + 1; i++)
                {
                    Blocks.Stone stone_ = new Blocks.Stone(textureAtlas);
                    world.SetBlock(new Vector2(x, 16 - i + 9), stone_);
                }
                for (int i = y + stoneY - 7; i < 4 + y + stoneY + 1; i++)
                {
                    Blocks.Cobblestone cobblestone_ = new Blocks.Cobblestone(textureAtlas);
                    world.SetBlockWithReplace(new Vector2(x, 16 - i + 10), cobblestone_);
                }
                GenerateOres(world, textureAtlas, x, y, stoneY, seed);

                Blocks.Bedrock bedrock_ = new Blocks.Bedrock(textureAtlas);
                world.SetBlock(new Vector2(x, 50), bedrock_);
            }
            GenerateTrees(-256, 256, maxTreesY.ToArray(), seed, world, textureAtlas);

            game.gameState = GameState.Playing;
        }
Ejemplo n.º 3
0
        private static void GenerateTrees(int minX, int maxX, int[] maxY, int seed, World world, TextureAtlas textureAtlas)
        {
            Random rand = new Random(seed + 3);
            for (int x = minX; x < maxX; x++)
            {
                if (rand.Next(12) == 0)
                {
                    int downWoodCountMax = 3;
                    int woodCountMax = new Random(seed + x + 2).Next(3, 5);

                    for (int i = 1; i <= downWoodCountMax; i++)
                    {
                        Blocks.Wood wood = new Blocks.Wood(textureAtlas);
                        world.SetBlock(new Vector2(x, 14 + downWoodCountMax + maxY[x + 256] - i), wood);
                    }

                    for (int i = woodCountMax; i >= 1; i--)
                    {
                        Blocks.Wood wood = new Blocks.Wood(textureAtlas);
                        world.SetBlock(new Vector2(x, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - i), wood);

                        int leavesCountMax = new Random(seed + x + 1).Next(2, 4);

                        for (int i_ = leavesCountMax; i_ >= 1; i_--)
                        {
                            Blocks.Leaves leaves = new Blocks.Leaves(textureAtlas);
                            world.SetBlock(new Vector2(x - i_, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - i), leaves);
                        }
                        for (int i_2 = 1; i_2 <= leavesCountMax; i_2++)
                        {
                            Blocks.Leaves leaves_ = new Blocks.Leaves(textureAtlas);
                            world.SetBlock(new Vector2(x + i_2, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - i), leaves_);
                        }
                    }

                    Blocks.Leaves leaves__ = new Blocks.Leaves(textureAtlas);
                    world.SetBlock(new Vector2(x - 1, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 2), leaves__);
                    Blocks.Leaves leaves__2 = new Blocks.Leaves(textureAtlas);
                    world.SetBlock(new Vector2(x + 1, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 2), leaves__2);

                    for (int i_ = 2; i_ >= 1; i_--)
                    {
                        Blocks.Leaves leaves__3 = new Blocks.Leaves(textureAtlas);
                        world.SetBlock(new Vector2(x - i_, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 1), leaves__3);
                    }
                    for (int i_2 = 1; i_2 <= 2; i_2++)
                    {
                        Blocks.Leaves leaves__4 = new Blocks.Leaves(textureAtlas);
                        world.SetBlock(new Vector2(x + i_2, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 1), leaves__4);
                    }

                    Blocks.Leaves leaves__5 = new Blocks.Leaves(textureAtlas);
                    world.SetBlock(new Vector2(x, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 2), leaves__5);
                    Blocks.Leaves leaves__6 = new Blocks.Leaves(textureAtlas);
                    world.SetBlock(new Vector2(x, 14 + woodCountMax - downWoodCountMax + maxY[x + 256] - woodCountMax - 1), leaves__6);
                }
            }
        }