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_); } } } }
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; }