private void ParseFile() { try { JsonBaseImportData data = JsonConvert.DeserializeObject <JsonBaseImportData>(File.ReadAllText(PathFile)); if (data != null) { Console.WriteLine("[INFO] GeneratorType: " + data.GeneratorType); switch (data.GeneratorType) { case GeneratorType.Terrain: string directoryName = System.IO.Path.GetDirectoryName(PathFile); WorldTerrainData worldTerrainData = data as WorldTerrainData; worldTerrainData.DirectoryPath = directoryName; mGenerator = new TerrainGenerator(worldTerrainData); break; case GeneratorType.Heightmap: HeightmapData heightmapData = data as HeightmapData; mGenerator = new HeightmapGenerator(heightmapData, mSchematic); break; case GeneratorType.Shader: ShaderData shaderData = data as ShaderData; mGenerator = new ShaderGenerator(shaderData, mSchematic); break; } } } catch (Exception e) { Console.WriteLine("[ERROR] Failed to parse the JSON file: " + e.Message); } }
public JsonToSchematic(string path) : base(path) { JsonBaseImportData data = JsonConvert.DeserializeObject <JsonBaseImportData>(File.ReadAllText(path)); switch (data.GeneratorType) { case GeneratorType.Terrain: string directoryName = Path.GetDirectoryName(path); WorldTerrainData worldTerrainData = data as WorldTerrainData; worldTerrainData.DirectoryPath = directoryName; mGenerator = new TerrainGenerator(worldTerrainData); break; case GeneratorType.City: break; } Console.WriteLine(data); }