public ClimateParameters( HemisphereMode hemisphere, HexDirections windDirection, float evaporationFactor, float highTemperature, float lowTemperature, float precipitationFactor, float runoffFactor, float seepageFactor, float temperatureJitter, float windStrength, float hexOuterRadius, int elevationMax, int waterLevel ) { this.hemisphere = hemisphere; this.windDirection = windDirection; this.evaporationFactor = evaporationFactor; this.highTemperature = highTemperature; this.lowTemperature = lowTemperature; this.precipitationFactor = precipitationFactor; this.runoffFactor = runoffFactor; this.seepageFactor = seepageFactor; this.temperatureJitter = temperatureJitter; this.windStrength = windStrength; this.hexOuterRadius = hexOuterRadius; this.elevationMax = elevationMax; this.waterLevel = waterLevel; }
private float GenerateTemperature( Hex hex, HemisphereMode hemisphere, int waterLevel, int elevationMax, int temperatureJitterChannel, float temperatureJitter, float lowTemperature, float highTemperature, float hexOuterRadius ) { if (_hexMap.HexOffsetRows == 0) { throw new System.ArgumentException( "Cannot generate temperature for a map with 0 height." ); } float latitude = (float)hex.CubeCoordinates.Z / (_hexMap.HexOffsetRows - 1f); if (hemisphere == HemisphereMode.Both) { latitude *= 2f; if (latitude > 1f) { latitude = 2f - latitude; } } else if (hemisphere == HemisphereMode.North) { latitude = 1f - latitude; } float temperature = Mathf.LerpUnclamped( lowTemperature, highTemperature, latitude ); temperature *= 1f - (hex.ViewElevation - waterLevel) / (elevationMax - waterLevel + 1f); float jitter = HexagonPoint.SampleNoise( hex.Position * 0.1f, hexOuterRadius, _hexMap.WrapSize )[temperatureJitterChannel]; temperature += (jitter * 2f - 1f) * temperatureJitter; temperature = Mathf.Clamp( temperature, lowTemperature, highTemperature ); return(temperature); }