| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 | using System;using System.Linq;using Excel2Json;using Fort23.UTool;using Utility;namespace Fort23.Mono{    public class RedDotGroupData    {        public int Id;        /// <summary>        /// 红点组ID        /// </summary>        public int GroupId;        /// <summary>        /// key层级 value id和红点信息        /// </summary>        public Map<int, Map<int, RedDotData>> AllRedDotData = new Map<int, Map<int, RedDotData>>();        public void Init(int id)        {            Id = id;            GroupId = ConfigComponent.Instance.Get<ReddotConfig>(id).GroupID;            AddRedDotData(id);            // Update();        }        public void AddRedDotData(int id)        {            ReddotConfig reddotConfig = ConfigComponent.Instance.Get<ReddotConfig>(id);            if (AllRedDotData.ContainsKey(reddotConfig.Layer))            {                RedDotData redDotData = new RedDotData();                redDotData.Id = id;                redDotData.GroupId = GroupId;                redDotData.Layer = reddotConfig.Layer;                redDotData.EnableId = reddotConfig.Enable;                AllRedDotData[reddotConfig.Layer].Add(redDotData.Id, redDotData);            }            else            {                Map<int, RedDotData> redDotDatas = new Map<int, RedDotData>();                RedDotData redDotData = new RedDotData();                redDotData.Id = id;                redDotData.GroupId = GroupId;                redDotData.Layer = reddotConfig.Layer;                redDotData.EnableId = reddotConfig.Enable;                redDotDatas.Add(redDotData.Id, redDotData);                AllRedDotData.Add(redDotData.Layer, redDotDatas);            }        }        public bool TargetLayerIsEnable(int layer)        {            bool isEnable = false;            int count = AllRedDotData.Keys.Count;            for (int i = count - 1; i >= 0; i--) //优先更新最底层红点            {                try                {                    int key = AllRedDotData.Keys.ToArray()[i];                    Map<int, RedDotData> redDotDatas = AllRedDotData[key];                    foreach (var redDotData in redDotDatas)                    {                        if (redDotData.Value.Layer >= layer)                        {                            if (redDotData.Value.isEnable)                            {                                isEnable = true;                                break;                            }                        }                    }                }                catch (Exception e)                {                    LogTool.Log(e);                    return false;                }            }            // foreach (var keyValuePair in AllRedDotData)            return isEnable;        }        public void Update()        {            int count = AllRedDotData.Keys.Count;            for (int i = count - 1; i >= 0; i--) //有限更新最底层红点            {                try                {                    int key = AllRedDotData.Keys.ToArray()[i];                    Map<int, RedDotData> redDotDatas = AllRedDotData[key];                    foreach (var keyValuePair in redDotDatas)                    {                        keyValuePair.Value.Update();                    }                }                catch (Exception e)                {                    LogTool.Log(e);                }            }        }    }}
 |