//セーブデータを読み込む public bool Load() { if (!File.Exists(saveFileName)) { return(false); } StreamReader sr = new StreamReader(saveFileName); try { isLoad = true; List <string[]> itemDates = new List <string[]>(); clearDungen = new Dictionary <int, int>(); armor = new ProtectionItem[4]; bag = new List <Item>(); int accessaryID = 0; depotEquipment = new List <Item>(); depotConsumption = new Dictionary <int, int>(); int bagNum = 0; int depotNum = 0; while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] strings = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (strings[0] == "floor") { clearDungen[int.Parse(strings[1])] = int.Parse(strings[2]); } else if (strings[0] == "money") { money = int.Parse(strings[1]); } else if (strings[0] == "leftHand") { if (strings[1] != "no") { string[] itemDate = new string[] { strings[1], strings[2], strings[3], strings[4], strings[5], }; itemDates.Add(itemDate); } else { itemDates.Add(null); } } else if (strings[0] == "rightHand") { if (strings[1] != "no") { string[] itemDate = new string[] { strings[1], strings[2], strings[3], strings[4], strings[5], }; itemDates.Add(itemDate); } else { itemDates.Add(null); } } else if (strings[0] == "arrow") { if (strings[1] != "no") { string[] itemDate = new string[] { strings[1], strings[2], strings[3] }; itemDates.Add(itemDate); } else { itemDates.Add(null); } } else if (strings[0] == "armor") { if (strings[1] != "no") { string[] itemDate = new string[] { strings[1], strings[2], strings[3], strings[4], strings[5], }; itemDates.Add(itemDate); } else { itemDates.Add(null); } } else if (strings[0] == "accessary") { if (strings[1] != "no") { accessaryID = int.Parse(strings[2]); } } else if (strings[0] == "bag") { bagNum++; if (strings[1] == "Consumption") { string[] itemDate = new string[] { strings[1], strings[2], strings[3], }; itemDates.Add(itemDate); } else if (strings[1] == "Accessary") { string[] itemDate = new string[] { strings[1], strings[2], }; itemDates.Add(itemDate); } else { string[] itemDate = new string[] { strings[1], strings[2], strings[3], strings[4], strings[5], }; itemDates.Add(itemDate); } } else if (strings[0] == "depot") { if (strings[1] == "Consumption") { depotConsumption.Add(int.Parse(strings[2]), int.Parse(strings[3])); } else if (strings[1] == "Accessary") { depotNum++; string[] itemDate = new string[] { strings[1], strings[2], }; itemDates.Add(itemDate); } else { depotNum++; string[] itemDate = new string[] { strings[1], strings[2], strings[3], strings[4], strings[5], }; itemDates.Add(itemDate); } } else if (strings[0] == "quest") { Quest q = questLoader.GetQuest(int.Parse(strings[1])); for (int i = 0; i < 3; i++) { if (i >= q.RequireID().Length) { break; } q.SetItemAmount(q.RequireID()[i], int.Parse(strings[i + 2])); } quest.Add(q); } else if (strings[0] == "guild") { guildRank = new PlayerGuildRank(int.Parse(strings[1]), int.Parse(strings[2])); } } sr.Close(); List <Item> items = itemManager.LoadSaveItem(itemDates); if (accessaryID != 0) { accessary = (AccessaryItem)itemManager.GetAccessary(accessaryID); } leftHand = (WeaponItem)items[0]; rightHand = (WeaponItem)items[1]; arrow = (ConsumptionItem)items[2]; armor[0] = (ProtectionItem)items[3]; armor[1] = (ProtectionItem)items[4]; armor[2] = (ProtectionItem)items[5]; armor[3] = (ProtectionItem)items[6]; for (int i = 7; i < 7 + bagNum; i++) { bag.Add(items[i]); } for (int i = 7 + bagNum; i < 7 + bagNum + depotNum; i++) { depotEquipment.Add(items[i]); } isLoad = false; return(true); } catch (Exception e) { Console.WriteLine(e); sr.Close(); return(false); } }