public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; bool[,] subArea = new bool[3, 3]; for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { this.GetComputedLandType(altitudeLandLayerGenerator, area, i, j, out LandType landType, out LandType secondType, out LandTransition landTransition); int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); GroundLandObject groundLandObject = new GroundLandObject(area.Left + j, area.Top + i, altitude, landType); GroundLandObject secondGroundLandObject = new GroundLandObject(area.Left + j, area.Top + i, altitude, secondType); secondGroundLandObject.SetTransition(landTransition); AssignGround(landChunk, i, j, altitude, altitudeOffset, groundLandObject, secondGroundLandObject); this.powerArea[i + 2, j + 2] = (int)this.GetLandTypeFromPower(altitude); } } landChunk.AddTypeInChunk(typeof(GroundLandObject)); return(seed); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator groundLandLayerGenerator = worldGenerator.Generators["defaultGround"]; ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; ALandLayerGenerator elementLandLayerGenerator = worldGenerator.Generators["element"]; bool isThereSandElement = false; Random random = new Random(seed); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); int elementIndex = random.Next(0, 8); int power = this.GetElementPower(elementLandLayerGenerator.GetComputedPowerAt(j, i)); LandType landType = (LandType)groundLandLayerGenerator.GetComputedPowerAt(j, i); if (landType == LandType.SAND) { if (power >= 8 && random.Next(0, 3) > 0 && altitudeOffset == 0) { float trueAltitude = altitudeLandLayerGenerator.GetPowerAt(new SFML.System.Vector2f(area.Left + j, area.Top + i)); if ((elementIndex == 1 || elementIndex == 3) && trueAltitude > 0.6 && random.Next(0, 4) > 0) { elementIndex -= 1; } GroundElementLandObject groundElement = new GroundElementLandObject(area.Left + j, area.Top + i, altitude, landType, elementIndex); LandCase landCase = landChunk.GetLandCase(i, j, altitude); landCase.LandOverGround = groundElement; isThereSandElement = true; } } } } if (isThereSandElement) { landChunk.AddTypeInChunk(typeof(GroundElementLandObject)); } return(random.Next()); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator grassLandLayerGenerator = worldGenerator.Generators["grass"]; ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; ALandLayerGenerator elementLandLayerGenerator = worldGenerator.Generators["element"]; bool isThereGrassElement = false; Random random = new Random(seed); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); int elementIndex = random.Next(0, 12); int power = this.GetElementPower(elementLandLayerGenerator.GetComputedPowerAt(j, i)); GrassType grassType = (GrassType)grassLandLayerGenerator.GetComputedPowerAt(j, i); if (power >= 2 && random.Next(0, 3) > 0 && altitudeOffset == 0 && grassType != GrassType.NONE) { GrassElementLandObject grassElement = new GrassElementLandObject(area.Left + j, area.Top + i, altitude, grassType, elementIndex); LandCase landCase = landChunk.GetLandCase(i, j, altitude); landCase.LandOverGround = grassElement; isThereGrassElement = true; } } } if (isThereGrassElement) { landChunk.AddTypeInChunk(typeof(GrassElementLandObject)); } return(random.Next()); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; bool[,] subArea = new bool[3, 3]; this.powerArea = new int[area.Height + 4, area.Width + 4]; for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int[,] subAreaInt = new int[3, 3]; int maxLocalAltitude = int.MinValue; maxLocalAltitude = this.GetComputedMatrix(altitudeLandLayerGenerator, i, j, ref subAreaInt); int diffAltitude = maxLocalAltitude - subAreaInt[1, 1]; this.powerArea[i + 2, j + 2] = diffAltitude; for (int offset = 0; offset < diffAltitude; offset++) { this.GetComputedLandType(area, ref subAreaInt, maxLocalAltitude, out LandTransition landTransition); if (landTransition != LandTransition.NONE) { AltitudeLandObject altitudeLandObject = new AltitudeLandObject(area.Left + j, area.Top + i, subAreaInt[1, 1], LandType.GRASS); landChunk.InitializeLandCase(i, j, subAreaInt[1, 1]); landChunk.GetLandCase(i, j, subAreaInt[1, 1]).LandWall = altitudeLandObject; altitudeLandObject.SetLandTransition(landTransition); } subAreaInt[1, 1]++; } } } landChunk.AddTypeInChunk(typeof(AltitudeLandObject)); return(seed); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; bool isThereWater = false; this.ConstructAltitudeArea(worldGenerator, area); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = this.powerArea[i + 1, j + 1]; int[,] subAreaInt = new int[3, 3]; int maxLocalAltitude = int.MinValue; maxLocalAltitude = this.GetComputedMatrix(i, j, ref subAreaInt); for (int z = altitude; z <= 0; z++) { this.GetComputedLandType(area, ref subAreaInt, maxLocalAltitude, out LandTransition landTransition); WaterLandObject waterLandObject = new WaterLandObject(area.Left + j, area.Top + i, z); waterLandObject.SetLandTransition(landTransition); landChunk.InitializeLandCase(i, j, z); landChunk.GetLandCase(i, j, z).LandWater = waterLandObject; isThereWater = true; subAreaInt[1, 1]++; } } } if (isThereWater) { landChunk.AddTypeInChunk(typeof(WaterLandObject)); } return(seed); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; bool[,] subArea = new bool[3, 3]; bool isThereMountain = false; this.ConstructMountainArea(worldGenerator, area); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); if ((altitude > 6 || (altitude == 6 && altitudeOffset > 0)) && altitude < 23) { LandCreationHelper.GetComputedLandType(this, area, i, j, out int mountainTypeInt, out int secondTypeInt, out LandTransition landTransition, out LandTransition secondLandTransition); //this.GetComputedLandType(area, i, j, out MountainType mountainType, out MountainType secondType, out LandTransition landTransition, out LandTransition secondLandTransition); MountainType mountainType = (MountainType)mountainTypeInt; MountainType secondType = (MountainType)secondTypeInt; MountainLandObject groundLandObject = null; MountainLandObject secondGroundLandObject = null; if (mountainType != MountainType.NONE) { groundLandObject = new MountainLandObject(area.Left + j, area.Top + i, altitude, mountainType); groundLandObject.SetTransition(landTransition); isThereMountain = true; } if (secondType != mountainType && secondType != MountainType.NONE) { secondGroundLandObject = new MountainLandObject(area.Left + j, area.Top + i, 0, secondType); secondGroundLandObject.SetTransition(secondLandTransition); isThereMountain = true; } bool onlyGround = altitude == 22 && altitudeOffset > 0; AssignGround(landChunk, i, j, altitude, altitudeOffset, groundLandObject, secondGroundLandObject, onlyGround); } } } if (isThereMountain) { landChunk.AddTypeInChunk(typeof(MountainLandObject)); } return(seed); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator mountainLandLayerGenerator = worldGenerator.Generators["mountain"]; ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; ALandLayerGenerator elementLandLayerGenerator = worldGenerator.Generators["element"]; bool isThereMountainElement = false; Random random = new Random(seed); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); int elementIndex = random.Next(0, 5); int power = this.GetElementPower(elementLandLayerGenerator.GetComputedPowerAt(j, i)); MountainType mountainType = (MountainType)mountainLandLayerGenerator.GetComputedPowerAt(j, i); if (mountainType == MountainType.PROJECTING) { if (elementIndex == 3 && random.Next(0, 3) > 0) { elementIndex = random.Next(0, 3); } } else if (mountainType == MountainType.ROUGH) { if (elementIndex < 3 && random.Next(0, 3) > 0) { elementIndex = 3; } } if (power >= 2 && random.Next(0, 3) > 0 && altitudeOffset == 0 && mountainType != MountainType.NONE) { MountainElementLandObject mountainElement = new MountainElementLandObject(area.Left + j, area.Top + i, altitude, mountainType, elementIndex); LandCase landCase = landChunk.GetLandCase(i, j, altitude); landCase.LandOverGround = mountainElement; isThereMountainElement = true; } } } if (isThereMountainElement) { landChunk.AddTypeInChunk(typeof(MountainElementLandObject)); } return(random.Next()); }