public static void InitialiseStarChart() { // read from json and initialise _starChart ScGalaxy gal = GeneralJsonSerializer.Deserialize<ScGalaxy>(Globals.GALAXY_CORE_DB, null); Int64 i = 1; Int64 j = 10000000; foreach (ScSolarSystem ss in gal.SolarSystems) { _scSolarSystems.Add(i, ss); i++; foreach (ScPlanet p in ss.Planets) { _scPlanets.Add(j, p); j++; } } }
// generates a json file that will be loaded in by galaxygencore to instantiate the star chart. static void Main(string[] args) { int numberOfSystems = 1; if (args.Length == 1) { int.TryParse(args[0], out numberOfSystems); } Console.Out.WriteLine("Creating galaxy with {0} Solarsystems...", numberOfSystems.ToString()); GalaxyCreator gc = new GalaxyCreator(); ScGalaxy gal = gc.GenerateGalaxy(numberOfSystems); GeneralJsonSerializer.SerializeAndSave(gal, Globals.GALAXY_CORE_DB); Console.Out.WriteLine("Json saved as {0}", Globals.GALAXY_CORE_DB); }
public static Galaxy Load() { return(GeneralJsonSerializer.Deserialize <Galaxy>(Globals.SERVER_SAVE_FILE, new GalaxyConverter())); }
public static void Save(Galaxy gal) { GeneralJsonSerializer.SerializeAndSave(gal, Globals.SERVER_SAVE_FILE); }