コード例 #1
0
    public static Dictionary <Pos, ILocation> MakeLocationsForOrganicGrowth(IGame game, MapGen mapGen, float pow = 2f)
    {
        IMap map = game.map;
        Dictionary <Pos, ILocation> locations = new Dictionary <Pos, ILocation>();

        ElevationBuilder elevationBuilder = new ElevationBuilder(MapUtil.nFromDims(map.xDim, map.yDim));

        elevationBuilder.SetElevationWithMidpointDisplacement(1);
        //elevationBuilder.TrimToDimensions(xDim, yDim);

        float[,] resources = elevationBuilder.Elevation;
        MapUtil.TransformMap(ref resources, MapUtil.dExponentiate, pow);
        for (int x = 0; x < map.xDim; x++)
        {
            for (int y = 0; y < map.yDim; y++)
            {
                Pos   p             = map.pathMap[new Loc(x, y).key()];
                bool  isLand        = mapGen.Elevation[x, y] < mapGen.seaLevel ? false : true;
                float startingValue = resources[x, y];
                locations[p] = new LocationOrganicGrowth(game, isLand, startingValue);
            }
        }

        return(locations);
    }
コード例 #2
0
    public static float[, ][] GetBiomesFromNoise2(IMap map, MapGen mapGen, int numCats)
    {
        float[, ][] biomes = new float[map.xDim, map.yDim][];

        for (int iCat = 0; iCat < numCats; iCat++)
        {
            ElevationBuilder elevationBuilder = new ElevationBuilder(MapUtil.nFromDims(map.xDim, map.yDim));
            elevationBuilder.SetElevationWithMidpointDisplacement(1);
            for (int x = 0; x < map.xDim; x++)
            {
                for (int y = 0; y < map.yDim; y++)
                {
                    biomes[x, y] = new float[numCats];
                    bool isAboveSeaLevel = mapGen.Elevation[x, y] > mapGen.seaLevel;
                    biomes[x, y][iCat] = isAboveSeaLevel ? elevationBuilder.Elevation[x, y] : 0f;
                }
            }
        }
        return(biomes);
    }
コード例 #3
0
ファイル: MapGen.cs プロジェクト: NickSchade/SamizdatEngine
    public void CreateElevation()
    {
        Debug.Log("Creating Elevation of Dimensions [" + xDim + "," + yDim + "]");
        elevationBuilder = new ElevationBuilder(MapUtil.nFromDims(xDim, yDim));
        elevationBuilder.SetElevationWithMidpointDisplacement(iExpand, bench: bench);
        //elevationBuilder.TrimToDimensions(xDim, yDim);
        Elevation = elevationBuilder.Elevation;

        xDim = Elevation.GetLength(0);
        yDim = Elevation.GetLength(1);
        Debug.Log("Creating Elevation of Dimensions [" + xDim + "," + yDim + "]");
        WaterFlux     = new float[xDim, yDim];
        Rain          = new float[xDim, yDim];
        Temperature   = new float[xDim, yDim];
        WindMagnitude = new float[xDim, yDim];
        Regions       = new float[xDim, yDim];
        Flatness      = new float[xDim, yDim];
        Fertility     = new float[xDim, yDim];
        Harbor        = new float[xDim, yDim];
        SetTemperature();
    }