Ejemplo n.º 1
0
 private static Task LoadItemBonus()
 {
     return(Task.Run(async() =>
     {
         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\\ItemBonus.json"))
                 using (var reader = new JsonTextReader(stream))
                     Collections.ItemBonus = serializer.Deserialize <Dictionary <int, ItemBonus> >(reader);
         }
         catch (Exception ex)
         {
             Output.WriteLine(ex);
             await ItemBonusConverter.Load();
             using (var stream = new StreamWriter("Database\\ItemBonus.json"))
                 serializer.Serialize(stream, Collections.ItemBonus, Collections.ItemBonus.GetType());
         }
     }));
 }
Ejemplo n.º 2
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?");
            }
        }