12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using Client.MirScenes;
- using Mir3Library;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Client
- {
- public class MonsterNotices
- {
- public static List<MonsterNotice> Notices;
- static string fileName;
- public static List<MonsterNotice> EnableNotices;
- public static void ConfigInit()
- {
- Notices =new List<MonsterNotice>();
- string ItemStrList = File.ReadAllText(@".\怪物汇总.csv");
- foreach (var itemStr in ItemStrList.Split('\n'))
- {
- string name = itemStr.Replace("\r", "");
- name= System.Text.RegularExpressions.Regex.Replace(name, @"\d", "");
- if (Notices.Any(t=>t.Name==name))
- {
- continue;
- }
- var notice = new MonsterNotice()
- {
- Name = name,
- };
- if (mir3lib.FindBossName(name))
- {
- notice.Enable = true;
- notice.IsNotice = true;
- }
- Notices.Add(notice);
- }
- File.WriteAllText(@".\Data\MonsterNotices.json", JsonConvert.SerializeObject(Notices));
- }
- public static void Init()
- {
- fileName = @".\Data\MonsterNotices_" + GameScene.User.Name + ".json";
- if (!File.Exists(fileName))
- {
- fileName = @".\Data\MonsterNotices.json";
- string json = File.ReadAllText(fileName);
- Notices = JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
- EnableNotices = Notices.Where(t => t.Enable == true).ToList();
- }
- else
- {
- string json = File.ReadAllText(fileName);
- Notices = JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
- json= File.ReadAllText(@".\Data\MonsterNotices.json");
- var AllNotices= JsonConvert.DeserializeObject<List<MonsterNotice>>(json);
- AllNotices.ForEach(t =>
- {
- if (!Notices.Any(tt => t.Name == tt.Name))
- { Notices.Add(t); }
- });
- EnableNotices = Notices.Where(t => t.Enable == true).ToList();
- }
-
- }
- public static void Save()
- {
- File.WriteAllText(@".\Data\MonsterNotices_" + GameScene.User.Name + ".json", JsonConvert.SerializeObject(Notices));
- }
- #region 初始化
- #endregion
- }
- public class MonsterNotice
- {
- public bool Enable { get; set; }
- public string Name { get; set; }
- //是否提醒
- public bool IsNotice { get; set; }
- }
- }
|