MonsterNotices.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Client.MirScenes;
  2. using Mir3Library;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace Client
  11. {
  12. public class MonsterNotices
  13. {
  14. public static List<MonsterNotice> Notices;
  15. static string fileName;
  16. public static List<MonsterNotice> EnableNotices;
  17. public static void ConfigInit()
  18. {
  19. Notices =new List<MonsterNotice>();
  20. string ItemStrList = File.ReadAllText(@".\怪物汇总.csv");
  21. foreach (var itemStr in ItemStrList.Split('\n'))
  22. {
  23. string name = itemStr.Replace("\r", "");
  24. name= System.Text.RegularExpressions.Regex.Replace(name, @"\d", "");
  25. if (Notices.Any(t=>t.Name==name))
  26. {
  27. continue;
  28. }
  29. var notice = new MonsterNotice()
  30. {
  31. Name = name,
  32. };
  33. if (mir3lib.FindBossName(name))
  34. {
  35. notice.Enable = true;
  36. notice.IsNotice = true;
  37. }
  38. Notices.Add(notice);
  39. }
  40. File.WriteAllText(@".\Data\MonsterNotices.json", JsonConvert.SerializeObject(Notices));
  41. }
  42. public static void Init()
  43. {
  44. fileName = @".\Data\MonsterNotices_" + GameScene.User.Name + ".json";
  45. if (!File.Exists(fileName))
  46. {
  47. fileName = @".\Data\MonsterNotices.json";
  48. string json = File.ReadAllText(fileName);
  49. Notices = JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
  50. EnableNotices = Notices.Where(t => t.Enable == true).ToList();
  51. }
  52. else
  53. {
  54. string json = File.ReadAllText(fileName);
  55. Notices = JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
  56. json= File.ReadAllText(@".\Data\MonsterNotices.json");
  57. var AllNotices= JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
  58. AllNotices.ForEach(t =>
  59. {
  60. if (!Notices.Any(tt => t.Name == tt.Name))
  61. { Notices.Add(t); }
  62. });
  63. EnableNotices = Notices.Where(t => t.Enable == true).ToList();
  64. }
  65. }
  66. public static void Save()
  67. {
  68. File.WriteAllText(@".\Data\MonsterNotices_" + GameScene.User.Name + ".json", JsonConvert.SerializeObject(Notices));
  69. }
  70. #region 初始化
  71. #endregion
  72. }
  73. public class MonsterNotice
  74. {
  75. public bool Enable { get; set; }
  76. public string Name { get; set; }
  77. //是否提醒
  78. public bool IsNotice { get; set; }
  79. }
  80. }