Exemple #1
0
 public static IHeightMap Build(LayeredNoiseParameters noise, int seed)
 {
     return(Build(
                minHeight: noise.MinHeight,
                maxHeight: noise.MaxHeight,
                scale: noise.Smoothness,
                seed: seed,
                numLayers: noise.NumLayers,
                amplitudeFactor: noise.ContributionMult,
                frequencyGrowth: noise.CompressionMult));
 }
    private void MapGeneration()
    {
        CaveGeneratorFactory factory = new CaveGeneratorFactory();

        ThreeTierCaveConfiguration ttcc = new ThreeTierCaveConfiguration();

        ttcc.CaveType = ThreeTierCaveType.Enclosed;

        AKSaigyouji.Modules.HeightMaps.HeightMapRocky ceiling_gen   = new AKSaigyouji.Modules.HeightMaps.HeightMapRocky();
        AKSaigyouji.HeightMaps.LayeredNoiseParameters ceiling_param = new AKSaigyouji.HeightMaps.LayeredNoiseParameters();
        ceiling_param.SetHeightRange(MIN_WALL, MAX_WALL);
        ceiling_param.SetSmoothness(10);
        ceiling_param.SetLayers(4, 0.5f, 2f);
        ceiling_gen.Properties      = ceiling_param;
        ttcc.CeilingHeightMapModule = ceiling_gen;
        ttcc.CeilingMaterial        = ceiling;

        AKSaigyouji.Modules.HeightMaps.HeightMapConstant floor_gen = new AKSaigyouji.Modules.HeightMaps.HeightMapConstant();
        floor_gen.Height          = 0;
        ttcc.FloorHeightMapModule = floor_gen;
        ttcc.FloorMaterial        = floor;

        ttcc.WallModule   = new AKSaigyouji.Modules.CaveWalls.CaveWallFlat();
        ttcc.WallMaterial = wall;

        AKSaigyouji.Modules.MapGeneration.MapGenCellAutomata map_gen = new AKSaigyouji.Modules.MapGeneration.MapGenCellAutomata();
        AKSaigyouji.Modules.MapGeneration.MapParameters      param   = new AKSaigyouji.Modules.MapGeneration.MapParameters
        {
            Length         = 100,
            Width          = 100,
            InitialDensity = 0.5f,
            ExpandTunnels  = true,
            BorderSize     = 1,
            MinWallSize    = 15,
            MinFloorSize   = 15
        };
        map_gen.Properties = param;
        ttcc.MapGenerator  = map_gen;

        ttcc.Scale = 2;

        ttcc.SetSeed(seed);

        CaveGenerator cg = factory.BuildThreeTierCaveGen(ttcc);
        //CaveGenerator cg = new MyCaveGenerator(ttcc);

        GameObject map = cg.Generate();
    }