/// <summary> /// データファイルを読み込む。 /// /// </summary> /// <param name="dir">フォルダ</param> private void ReadDataFiles(string dir) { string itemsPath = System.IO.Path.Combine(dir, "Items.json"); if (System.IO.File.Exists(itemsPath)) { items = DataItemListParser.Read(itemsPath); } string weaponsPath = System.IO.Path.Combine(dir, "Weapons.json"); if (System.IO.File.Exists(weaponsPath)) { weapons = DataWeaponListParser.Read(weaponsPath); } string armorsPath = System.IO.Path.Combine(dir, "Armors.json"); if (System.IO.File.Exists(armorsPath)) { armors = DataArmorListParser.Read(armorsPath); } Shops.Clear(); string shopPath = System.IO.Path.Combine(dir, "Shops.json"); if (System.IO.File.Exists(shopPath)) { Shops = DataShopListReader.Read(shopPath); if (!Shops.Contains(null)) { Shops.Add(null); } Shops.Sort((a, b) => { if (a == null) { return(-1); } else if (b == null) { return(1); } else { return(a.Id - b.Id); } }); } else { Shops.Add(null); Shops.Add(new DataShop() { Id = 1 }); } }
/// <summary> /// データファイルを読み出す。 /// </summary> /// <param name="dir">フォルダ</param> private void ReadDataFiles(string dir) { string itemsPath = System.IO.Path.Combine(dir, "Items.json"); if (System.IO.File.Exists(itemsPath)) { items = DataItemListParser.Read(itemsPath); } string weaponsPath = System.IO.Path.Combine(dir, "Weapons.json"); if (System.IO.File.Exists(weaponsPath)) { weapons = DataWeaponListParser.Read(weaponsPath); } string armorsPath = System.IO.Path.Combine(dir, "Armors.json"); if (System.IO.File.Exists(armorsPath)) { armors = DataArmorListParser.Read(armorsPath); } string enemiesPath = System.IO.Path.Combine(dir, "Enemies.json"); if (System.IO.File.Exists(enemiesPath)) { enemies = DataEnemyListParser.Read(enemiesPath); } string questsPath = System.IO.Path.Combine(dir, "Quests.json"); if (System.IO.File.Exists(questsPath)) { Quests = DataQuestListReader.Read(questsPath); if (!Quests.Contains(null)) { Quests.Add(null); } Quests.Sort((a, b) => { if (a == null) { return(-1); } else if (b == null) { return(1); } else { return(a.Id - b.Id); } }); } }
/// <summary> /// データをダンプする。 /// </summary> /// <param name="path">ファイルパス</param> private static void DumpDataProc(string path) { try { string fileName = System.IO.Path.GetFileName(path); if (fileName.Equals("Actors.json")) { DumpItems(DataActorListParser.Read(path)); } else if (fileName.Equals("Items.json")) { DumpItems(DataItemListParser.Read(path)); } else if (fileName.Equals("Weapons.json")) { DumpItems(DataWeaponListParser.Read(path)); } else if (fileName.Equals("Armors.json")) { DumpItems(DataArmorListParser.Read(path)); } else if (fileName.Equals("Enemies.json")) { DumpItems(DataEnemyListParser.Read(path)); } else if (path.EndsWith(".json")) { DumpGenericJsonData(path); } } catch (Exception e) { Console.WriteLine(e); } Console.ReadKey(); }