/// <summary> /// Generates the world using provided generator /// </summary> /// <param name="generator">The provided generator</param> /// <param name="progressBar">The progressbar to mark progress on</param> public void Generate(IMapGenerator generator, ProgressBar progressBar = null) { if (generator == null) { throw new ArgumentNullException("The generator can not be null!"); } generator.Generate(this, progressBar); }
public void CreateNewMap() { for (int i = 0; i < ActiveMap.Count; i++) { MapGenerator = ActiveMap[i]; MapGenerator.Setup(MapWidth, MapHeight, RandomMap); RandomMap = MapGenerator.Generate(); } }
public IEnumerator Load(IMapGenerator map_generator) { map_generator_ = map_generator; map_factory_ = GetComponent <MapFactory>(); yield return(StartCoroutine(map_generator_.Generate())); Reset(map_generator_.GetMap()); }
public static int Main(string[] args) { var app = new CommandLineApplication(false); var folderOption = app.Option("-f | --folder", "Specifies input folder", CommandOptionType.SingleValue); var outputOption = app.Option("-o | --output", "Specifies the output image's file name", CommandOptionType.SingleValue); var mapOption = app.Option("-m | --map", "Specifies the map's file name", CommandOptionType.SingleValue); var powTwoOption = app.Option("-2 | --pow2", "Forces that the output to have power of two dimensions", CommandOptionType.NoValue); var squareOption = app.Option("-s | --square", "Forces that the output to be have equal width and length", CommandOptionType.NoValue); var maxWidthOption = app.Option("-w | --maxwidth", "Specifies the maximum allowed output width", CommandOptionType.SingleValue); var maxHeightOption = app.Option("-h | --maxwidth", "Specifies the maximum allowed output height", CommandOptionType.SingleValue); var paddingOption = app.Option("-p | --padding", "Specifies the padding in pixel between packed subimages", CommandOptionType.SingleValue); app.HelpOption("-? | -h | --help"); app.OnExecute(() => { if (!folderOption.HasValue() || !outputOption.HasValue()) { Console.WriteLine("An input folder and an output filename are required"); return(1); } var inputDir = new DirectoryInfo(folderOption.Value()); var inputFiles = inputDir.GetFiles().Where(d => ImagePacker.SupportedImageExtensions.Contains(d.Extension.ToLower())).ToArray(); if (!inputFiles.Any()) { Console.WriteLine("No supported files found"); return(1); } var outFile = new FileInfo(outputOption.Value()); var outEncoder = ImagePacker.GetEncoderFromExtension(outFile.Extension); if (outEncoder == null) { Console.WriteLine("Unsupported output file format"); return(1); } var outMap = mapOption.HasValue() ? new FileInfo(mapOption.Value()) : null; IMapGenerator outGenerator = null; if (outMap != null) { outGenerator = MapGenerators.FirstOrDefault(d => d.MapExtension == outMap.Extension.ToLower()); if (outGenerator == null) { Console.WriteLine("Unsupported output map format"); return(1); } } var valueParsed = int.TryParse(maxWidthOption.Value(), out var maxWidth); if (!valueParsed) { maxWidth = DefaultSize; } valueParsed = int.TryParse(maxHeightOption.Value(), out var maxHeight); if (!valueParsed) { maxHeight = DefaultSize; } valueParsed = int.TryParse(paddingOption.Value(), out var padding); if (!valueParsed) { padding = DefaultPadding; } var packer = new ImagePacker(); packer.PackImage(inputFiles, powTwoOption.HasValue(), squareOption.HasValue(), maxWidth, maxHeight, padding, out var packedImage, out var packedMap); using (var outStream = outFile.Open(FileMode.Create)) { packedImage.Save(outStream, outEncoder); } if (outGenerator != null) { var mapBytes = outGenerator.Generate(packedMap); using (var outStream = outMap.Open(FileMode.Create)) { outStream.Write(mapBytes, 0, mapBytes.Length); } } return(0); }); return(app.Execute(args)); }
public void GenerateBy(IMapGenerator mapGenerator) { (_texture, _vertexArray) = mapGenerator.Generate(); }
public void Initialize(Size size) { Size = size; _mapGenerator.Generate(this); }