123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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 ItemNotices
- {
- public static List<ItemNotice> Notices;
- static string fileName;
- public static List<ItemNotice> EnableNotices;
- public static void Init()
- {
- fileName = @".\Data\ItemNotices_" +GameScene.User.Name+".json";
- if (!File.Exists(fileName))
- {
- fileName = @".\Data\ItemNotices.json";
- }
- string json = File.ReadAllText(fileName);
- Notices = JsonConvert.DeserializeObject<List<ItemNotice>>(json);
- if (fileName!= @".\Data\ItemNotices.json")
- {
- json= File.ReadAllText(@".\Data\ItemNotices.json");
- var n= JsonConvert.DeserializeObject<List<ItemNotice>>(json);
- foreach (var item in n)
- {
- if (!Notices.Any(t=>t.Index==item.Index))
- {
- Notices.Add(item);
- }
- }
- }
- EnableNotices= Notices.Where(t=>t.Enable).ToList();
- }
- public static void Save()
- {
- File.WriteAllText(@".\Data\ItemNotices_" + GameScene.User.Name + ".json", JsonConvert.SerializeObject(Notices));
- }
- public static void AddNotice(ItemNotice notice)
- {
- Notices.Add(notice);
- }
- public static void ConfigInit()
- {
- Notices = new List<ItemNotice>();
- string ItemStrList = File.ReadAllText(@".\物品汇总.csv");
- foreach (var itemStr in ItemStrList.Split('\n'))
- {
- itemStr.Replace("\r", "");
- var strs = itemStr.Split(',');
- int id;
- try
- {
- id = int.Parse(strs[0]);
- }
- catch (Exception)
- {
- continue;
- }
- string name = strs[1];
- var notice = new ItemNotice()
- {
- Index = id,
- Name = name,
- Type = int.Parse(strs[2]),
- Grade = int.Parse(strs[3]),
- };
- if (mir3lib.FindItemName(name))
- {
- notice.Enable = true;
- notice.Grade4 = true;
- notice.IsNotice = true;
- }
- else
- {
- if (notice.Grade == 4)
- {
- notice.Grade4 = true;
- }
- else if (notice.Grade == 3)
- {
- notice.Grade3 = true;
- }
- }
- Notices.Add(notice);
- }
- File.WriteAllText(@".\Data\ItemNotices.json", JsonConvert.SerializeObject(Notices));
- }
- }
- public class ItemNotice
- {
- public bool Enable { get; set; }
- public int Index { get; set; }
- public string Name { get; set; }
- //是否极品
- public bool Grade4 { get; set; }
- //是否高级
- public bool Grade3 { get; set; }
- //是否提醒
- public bool IsNotice { get; set; }
- //是否自动捡取
- public bool IsAutoPickUp { get; set; } = true;
- //是否显示名字
- public bool IsShowName { get; set; } = true;
- public int Type { get; set; }
- public int Grade { get; set; }
- }
- }
|