public GameObject GetType(MountainType type) { if (type == MountainType.normal) { return normalTile; } else if (type == MountainType.volcano) { return volcanoTile; } return null; }
public void ChangePathType(PathType newType) { PathTypeState state = null; lastSetType = newType; switch (newType) { case PathType.city: state = new CityType(); break; case PathType.desert: state = new DesertType(); break; case PathType.field: state = new FieldType(); break; case PathType.forest: state = new ForestType(); break; case PathType.mountain: state = new MountainType(); break; case PathType.road: state = new RoadType(); break; case PathType.rocks: state = new RocksType(); break; case PathType.swamp: state = new SwampType(); break; case PathType.water: state = new WaterType(); break; } if (_pathType != null) { _pathType.OnExitState(); } _pathType = state; _pathType.OnEnterState(this); }
public MountainLandObject(int positionX, int positionY, int positionZ, MountainType grassType) : base(positionX, positionY, positionZ, LandType.STONE) { this.LandMountainType = grassType; }
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()); }
public MountainElementLandObject(int positionX, int positionY, int positionZ, MountainType mountainType, int elementIndex) : base(positionX, positionY, positionZ) { this.LandMountainType = mountainType; this.ElementIndex = elementIndex; }