Exemple #1
0
        static bool GenerateMap(MapGenArgs genArgs)
        {
            MapGenTheme theme = MapGenTheme.Forest;

            if (genArgs.Args.Length > 0 &&
                !CommandParser.GetEnum(genArgs.Player, genArgs.Args, "Seed", ref theme))
            {
                return(false);
            }

            MapGenTemplate         templ = (MapGenTemplate)Enum.Parse(typeof(MapGenTemplate), genArgs.Theme.Substring(3), true);
            fCraftMapGeneratorArgs args  = fCraftMapGeneratorArgs.MakeTemplate(templ);
            Level map = genArgs.Level;

            float ratio = map.Height / 96.0f;

            args.MaxHeight    = (int)Math.Round(args.MaxHeight * ratio);
            args.MaxDepth     = (int)Math.Round(args.MaxDepth * ratio);
            args.SnowAltitude = (int)Math.Round(args.SnowAltitude * ratio);

            args.Theme      = theme;
            args.AddTrees   = theme == MapGenTheme.Forest;
            args.AddWater   = theme != MapGenTheme.Desert;
            args.WaterLevel = (map.Height - 1) / 2;

            fCraftMapGenerator generator = new fCraftMapGenerator(args);

            generator.Generate(map);
            return(true);
        }
Exemple #2
0
        static bool GenerateMap(MapGenArgs genArgs)
        {
            MapGenTheme theme = MapGenTheme.Forest;

            if (genArgs.Args != "" && !Utils.TryParseEnum(genArgs.Args, out theme))
            {
                string[] themes = Enum.GetNames(typeof(MapGenTheme));
                Player.Message(genArgs.Player, "Seed must be one of the following themes: " + themes.Join());
                return(false);
            }

            MapGenTemplate         templ = (MapGenTemplate)Enum.Parse(typeof(MapGenTemplate), genArgs.Theme.Substring(3), true);
            fCraftMapGeneratorArgs args  = fCraftMapGeneratorArgs.MakeTemplate(templ);
            Level map = genArgs.Level;

            float ratio = map.Height / 96.0f;

            args.MaxHeight    = (int)Math.Round(args.MaxHeight * ratio);
            args.MaxDepth     = (int)Math.Round(args.MaxDepth * ratio);
            args.SnowAltitude = (int)Math.Round(args.SnowAltitude * ratio);

            args.Theme      = theme;
            args.AddTrees   = theme == MapGenTheme.Forest;
            args.AddWater   = theme != MapGenTheme.Desert;
            args.WaterLevel = (map.Height - 1) / 2;

            fCraftMapGenerator generator = new fCraftMapGenerator(args);

            generator.Generate(map);
            return(true);
        }