GenLayerBiome.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using MineCase.World.Biomes;
  3. namespace MineCase.Algorithm.World.Layer
  4. {
  5. public class GenLayerBiome : GenLayer
  6. {
  7. public GenLayerBiome(int seed, GenLayer parent)
  8. : base(seed, parent)
  9. {
  10. }
  11. public override int[,] GetInts(int areaX, int areaY, int areaWidth, int areaHeight)
  12. {
  13. int[,] parentResult = _parent.GetInts(areaX, areaY, areaWidth, areaHeight);
  14. for (int i = 0; i < areaHeight; ++i)
  15. {
  16. for (int j = 0; j < areaWidth; ++j)
  17. {
  18. Random random = new Random(GetChunkSeed(areaX + j, areaY + i));
  19. if (parentResult[i, j] == (int)BiomeId.Plains)
  20. {
  21. int r = random.Next(10);
  22. if (r >= 0 && r < 1)
  23. {
  24. parentResult[i, j] = (int)BiomeId.Forest;
  25. }
  26. else if (r >= 1 && r < 2)
  27. {
  28. parentResult[i, j] = (int)BiomeId.ExtremeHills;
  29. }
  30. else if (r >= 2 && r < 3)
  31. {
  32. parentResult[i, j] = (int)BiomeId.Swampland;
  33. }
  34. else if (r >= 3 && r < 5)
  35. {
  36. parentResult[i, j] = (int)BiomeId.Desert;
  37. }
  38. else if (r >= 5 && r < 7)
  39. {
  40. parentResult[i, j] = (int)BiomeId.Taiga;
  41. }
  42. }
  43. }
  44. }
  45. return parentResult;
  46. }
  47. }
  48. }