Beispiel #1
0
 public void BuildRain(RainMethod pm, Benchmark bench = null)
 {
     Benchmark.Start(bench, "Rain"); // etc
     if (pm == RainMethod.Equal)
     {
         BuildRainByEqual();
     }
     else if (pm == RainMethod.Noise)
     {
         BuildRainByNoise();
     }
     else if (pm == RainMethod.Wind)
     {
         WindSpawn           ws = WindSpawn.TradeLinear;
         WindRainType        rt = WindRainType.HeatBasedContinuous;
         WindEvaporationType et = WindEvaporationType.WaterAndHeat;
         WindTurnType        wt = WindTurnType.TerrainBased;
         BuildRainByWind(1000, ws, rt, et, wt, bench);
         MapUtil.TransformMapMinMax(ref Rain, MapUtil.dNormalize);
     }
     if (bench != null)
     {
         bench.EndBenchmark("Rain");
     }
 }
    private void BuildRainByWind(int maxIter, WindSpawn windSpawn, WindRainType rainType, WindEvaporationType evapType, WindTurnType windTurnType, Benchmark bench = null)
    {
        if (bench != null)
        {
            bench.StartBenchmark("Wind");
        }
        List <Wind> winds = new List <Wind>();

        for (int x = 0; x < xDim; x++)
        {
            for (int y = 0; y < yDim; y++)
            {
                WindVectorsList[x, y] = new List <Vec>();
                Wind w = new Wind(x, y, Elevation, windSpawn);
                WindVectorsList[x, y].Add(new Vec(w.velocity.x, w.velocity.y));
                winds.Add(w);
            }
        }
        int iter          = 0;
        int numberOfWinds = winds.Count;

        while (iter < maxIter)
        {
            numberOfWinds = winds.Count;
            if (numberOfWinds == 0)
            {
                break;
            }
            else
            {
                BuildRainByWindWorkhorse(ref winds, windSpawn, rainType, evapType, windTurnType);
            }
            iter++;
        }
        MapUtil.TransformMap(ref Rain, MapUtil.dExponentiate, 0.125f);
        TabulateWindflow();
        if (bench != null)
        {
            bench.EndBenchmark("Wind");
        }
    }
Beispiel #3
0
 public void Rain(WindRainType rt, ref float[,] Rain, float [,] Elevation, float seaLevel)
 {
     if (rt == WindRainType.UphillDiscrete)
     {
         if (deltaHeight > 0f && Elevation[approxMapLoc.x, approxMapLoc.y] > seaLevel)
         {
             float rainAmount = 0.1f * Water;
             RainWorkhorse(ref Rain, rainAmount);
         }
     }
     else if (rt == WindRainType.HeatBasedDiscrete)
     {
         if (deltaTemp < -0f && Elevation[approxMapLoc.x, approxMapLoc.y] > seaLevel)
         {
             float rainAmount = 0.1f * Water;
             RainWorkhorse(ref Rain, rainAmount);
         }
     }
     else if (rt == WindRainType.UphillContinuous)
     {
         if (deltaHeight > 0f && Elevation[approxMapLoc.x, approxMapLoc.y] > seaLevel)
         {
             float rainAmount = deltaHeight * Water;
             RainWorkhorse(ref Rain, rainAmount);
         }
     }
     else if (rt == WindRainType.HeatBasedContinuous)
     {
         if (deltaTemp < -0f && Elevation[approxMapLoc.x, approxMapLoc.y] > seaLevel)
         {
             float rainAmount = -deltaTemp * Water;
             RainWorkhorse(ref Rain, rainAmount);
         }
         if (Water > 10)
         {
             float rainAmount = 0.1f * Water;
             RainWorkhorse(ref Rain, rainAmount);
         }
     }
 }
Beispiel #4
0
 private void BuildRainByWindWorkhorse(ref List <Wind> winds, WindSpawn windSpawn, WindRainType rainType, WindEvaporationType evapType, WindTurnType windTurnType)
 {
     //  Combine Winds at the same location
     CombineWinds(ref winds, windSpawn);
     // Add to WindFlow
     foreach (Wind w in winds)
     {
         WindVectorsList[w.approxMapLoc.x, w.approxMapLoc.y].Add(new Vec(w.velocity.x, w.velocity.y));
     }
     //  Move wind in the direction vector
     foreach (Wind w in winds)
     {
         w.Blow(Elevation, Temperature);
     }
     //  If the wind moves off the map, remove it
     RemoveOffWindMaps(ref winds);
     //  Rain
     foreach (Wind w in winds)
     {
         w.Rain(rainType, ref Rain, Elevation, seaLevel);
     }
     // Evaporate
     foreach (Wind w in winds)
     {
         w.Evaporate(evapType, Elevation, Temperature, seaLevel);
     }
     // Turn Wind
     foreach (Wind w in winds)
     {
         w.TurnWind(windTurnType, Elevation, seaLevel);
     }
 }