public override ILandObject Clone(LandTransition wallLandTransition) { if (wallLandTransition != LandTransition.NONE) { MountainElementLandObject mountainLandObject = new MountainElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandMountainType, this.ElementIndex); return(mountainLandObject); } return(null); }
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()); }
public override ILandObject Clone() { MountainElementLandObject mountainLandObject = new MountainElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandMountainType, this.ElementIndex); return(mountainLandObject); }