public int WeaponLvLoad(int Id, int order) { string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); if (!Directory.Exists(Path.Combine(MainFolder, "Bin"))) { Directory.CreateDirectory(Path.Combine(MainFolder, "Bin")); } var binPath = Path.Combine(MainFolder, "Bin", "WeaponSkills.bin"); if (File.Exists(binPath)) { var items = new Dictionary <int, SkillLvTable>(); var bytes = File.ReadAllBytes(binPath); using (var memoryStream = new MemoryStream(bytes)) using (var reader = new BinaryReader(memoryStream)) { while (memoryStream.Position < memoryStream.Length) { int paramID = reader.ReadInt32(); var item = new SkillLvTable { SkillLv1 = reader.ReadInt32(), SkillLv2 = reader.ReadInt32(), }; items.Add(paramID, item); } memoryStream.Dispose(); memoryStream.Close(); reader.Dispose(); reader.Close(); } if (items.ContainsKey(Id)) { if (order == 1) { return(items[Id].SkillLv1); } else { return(items[Id].SkillLv2); } } } return(1); }
public void WeaponLvSave(int Id, int order, int Lv) { if (!this.DeckIsEnd && !this.ListIsEnd) return; string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); if (!Directory.Exists(Path.Combine(MainFolder, "Bin"))) Directory.CreateDirectory(Path.Combine(MainFolder, "Bin")); var binPath = Path.Combine(MainFolder, "Bin", "WeaponSkills.bin"); var items = new Dictionary<int, SkillLvTable>(); if (File.Exists(binPath)) { var bytes = File.ReadAllBytes(binPath); using (var memoryStream = new MemoryStream(bytes)) using (var reader = new BinaryReader(memoryStream)) { while (memoryStream.Position < memoryStream.Length) { int paramID = reader.ReadInt32(); var item = new SkillLvTable { SkillLv1 = reader.ReadInt32(), SkillLv2 = reader.ReadInt32(), }; items.Add(paramID, item); } memoryStream.Dispose(); memoryStream.Close(); reader.Dispose(); reader.Close(); } //파일 읽기 종료 if (items.ContainsKey(Id))//키를 가지고 있으면 해당 키에 해당하는 레벨을 조정 { if (order == 1) items[Id].SkillLv1 = Lv; else items[Id].SkillLv2 = Lv; } else { var temp = new SkillLvTable(); if (order == 1) { temp.SkillLv1 = Lv; } else { temp.SkillLv2 = Lv; } items.Add(Id, temp); } } else { var temp = new SkillLvTable(); if (order == 1) { temp.SkillLv1 = Lv; if (temp.SkillLv2 < 1 || temp.SkillLv2 > 15) temp.SkillLv2 = 1; } else { temp.SkillLv2 = Lv; if (temp.SkillLv1 < 1 || temp.SkillLv1 > 15) temp.SkillLv1 = 1; } items.Add(Id, temp); } using (var fileStream = new FileStream(binPath, FileMode.Create, FileAccess.Write, FileShare.None)) using (var writer = new BinaryWriter(fileStream)) { foreach (var item in items) { writer.Write(item.Key); writer.Write(item.Value.SkillLv1); writer.Write(item.Value.SkillLv2); } fileStream.Dispose(); fileStream.Close(); writer.Dispose(); writer.Close(); } }
public int WeaponLvLoad(int Id, int order) { string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); if (!Directory.Exists(Path.Combine(MainFolder, "Bin"))) Directory.CreateDirectory(Path.Combine(MainFolder, "Bin")); var binPath = Path.Combine(MainFolder, "Bin", "WeaponSkills.bin"); if (File.Exists(binPath)) { var items = new Dictionary<int, SkillLvTable>(); var bytes = File.ReadAllBytes(binPath); using (var memoryStream = new MemoryStream(bytes)) using (var reader = new BinaryReader(memoryStream)) { while (memoryStream.Position < memoryStream.Length) { int paramID = reader.ReadInt32(); var item = new SkillLvTable { SkillLv1 = reader.ReadInt32(), SkillLv2 = reader.ReadInt32(), }; items.Add(paramID, item); } memoryStream.Dispose(); memoryStream.Close(); reader.Dispose(); reader.Close(); } if (items.ContainsKey(Id)) { if (order == 1) return items[Id].SkillLv1; else return items[Id].SkillLv2; } } return 1; }
public void WeaponLvSave(int Id, int order, int Lv) { if (!this.DeckIsEnd && !this.ListIsEnd) { return; } string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); if (!Directory.Exists(Path.Combine(MainFolder, "Bin"))) { Directory.CreateDirectory(Path.Combine(MainFolder, "Bin")); } var binPath = Path.Combine(MainFolder, "Bin", "WeaponSkills.bin"); var items = new Dictionary <int, SkillLvTable>(); if (File.Exists(binPath)) { var bytes = File.ReadAllBytes(binPath); using (var memoryStream = new MemoryStream(bytes)) using (var reader = new BinaryReader(memoryStream)) { while (memoryStream.Position < memoryStream.Length) { int paramID = reader.ReadInt32(); var item = new SkillLvTable { SkillLv1 = reader.ReadInt32(), SkillLv2 = reader.ReadInt32(), }; items.Add(paramID, item); } memoryStream.Dispose(); memoryStream.Close(); reader.Dispose(); reader.Close(); } //파일 읽기 종료 if (items.ContainsKey(Id)) //키를 가지고 있으면 해당 키에 해당하는 레벨을 조정 { if (order == 1) { items[Id].SkillLv1 = Lv; } else { items[Id].SkillLv2 = Lv; } } else { var temp = new SkillLvTable(); if (order == 1) { temp.SkillLv1 = Lv; } else { temp.SkillLv2 = Lv; } items.Add(Id, temp); } } else { var temp = new SkillLvTable(); if (order == 1) { temp.SkillLv1 = Lv; if (temp.SkillLv2 < 1 || temp.SkillLv2 > 15) { temp.SkillLv2 = 1; } } else { temp.SkillLv2 = Lv; if (temp.SkillLv1 < 1 || temp.SkillLv1 > 15) { temp.SkillLv1 = 1; } } items.Add(Id, temp); } using (var fileStream = new FileStream(binPath, FileMode.Create, FileAccess.Write, FileShare.None)) using (var writer = new BinaryWriter(fileStream)) { foreach (var item in items) { writer.Write(item.Key); writer.Write(item.Value.SkillLv1); writer.Write(item.Value.SkillLv2); } fileStream.Dispose(); fileStream.Close(); writer.Dispose(); writer.Close(); } }