Exemple #1
0
        public static async Task Convert()
        {
            try
            {
                if (!Directory.Exists("RAW"))
                {
                    Output.WriteLine("RAW not found! Restoring!");
                    //await Content.Content.RestoreAsync();
                    Output.WriteLine("RAW Restored!");
                }
                if (!Directory.Exists("Database"))
                {
                    Directory.CreateDirectory("Database");
                }

                Output.WriteLine("Rebuilding");
                UniqueIdGenerator.Load();
                MapManager.Load(@"RAW\ini\GameMap.dat", Environment.CurrentDirectory + "\\RAW\\");
                Item.ItemFactory.LoadDb();
                await Task.WhenAll(MonsterDb.Load(), PortalDb.Load(), MagicTypeConverter.Load(), ItemBonusConverter.Load(), StatpointConverter.Load(), LevelExpConverter.Load());

                NpcDb.Load();
                await Db.SaveAsJsonAsync(SaveType.All);
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
                Output.WriteLine("N***a, I couldn't load the Db, nor convert your old db. What the f**k are you doing?");
            }
        }
Exemple #2
0
 private static Task LoadNpcs()
 {
     return(Task.Run(() =>
     {
         var serializer = new JsonSerializer {
             DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.Auto, Formatting = Formatting.Indented, Converters = { new BoolConverter() }
         };
         try
         {
             using (var stream = new StreamReader("Database\\Npcs.json"))
                 using (var reader = new JsonTextReader(stream))
                     Collections.Npcs = serializer.Deserialize <Dictionary <int, YiObj> >(reader);
         }
         catch (Exception ex)
         {
             Output.WriteLine(ex);
             NpcDb.Load();
             using (var stream = new StreamWriter("Database\\Npcs.json"))
                 serializer.Serialize(stream, Collections.Npcs, Collections.Npcs.GetType());
         }
     }));
 }