コード例 #1
0
        /// <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
                });
            }
        }