Beispiel #1
0
    public void CreateWorldModel(Grid worldGrid)
    {
        Grid  = worldGrid;
        Tiles = new Tile[worldGrid.Width, worldGrid.Height];

        LayeredPerlinNoise elevationFunction     = new LayeredPerlinNoise(mElevationNoiseParams);
        LayeredPerlinNoise precipitationFunction = new LayeredPerlinNoise(mPrecipitationNoiseParams);

        worldGrid.IterateOverPoints((point) =>
        {
            float elevation = elevationFunction.Sample(point.Position);
            //TODO use latitude to convert elevation to temperature
            float precipation = precipitationFunction.Sample(point.Position);

            Biome biomeData = DetermineBiome(elevation, precipation);

            //Debug.LogFormat("El: {0}, Pre: {1}, Biome: {2}", elevation, precipation, biomeData.Name);

            Tiles[point.GridIndex.x, point.GridIndex.y] = new Tile()
            {
                BiomeData     = biomeData,
                Precipitation = precipation,
                Elevation     = elevation
            };
        });
    }
Beispiel #2
0
 public float Sample(float x, float y)
 {
     return(mNoiseFunction.Sample(x, y) * (mTaperFunction?.Sample(x, y) ?? 1f));
 }