/// <summary> /// 移除开关红点回调 /// </summary> /// <param name="key"></param> static void RemoveDotAction(RedDotKey key) { if (_redOpenDotActionDic.ContainsKey(key)) { _redOpenDotActionDic.Remove(key); } }
/// <summary> /// 移除回调 /// </summary> /// <param name="redDotKey">key</param> static void RemoveAction(RedDotKey redDotKey) { if (_redDotActionDic.ContainsKey(redDotKey)) { _redDotActionDic.Remove(redDotKey); } }
/// <summary> /// 更新红点 /// </summary> /// <param name="key"></param> /// <param name="dotTra"></param> public static void UpdateRedDot(RedDotKey key) { if (!_isInitial) { Initial(); } if (_redOpenDotActionDic.ContainsKey(key)) { if (_redOpenDotActionDic[key] != null) { bool isOpen = _redOpenDotActionDic[key].Invoke(); if (_redDotTraDic.ContainsKey(key)) { if (_redDotTraDic[key] != null) { _redDotTraDic[key].gameObject.SetActive(isOpen); } } } } //如果是商城,任务,订单,仓库,装饰更新红点 需要同时更新大厅庄园的红点 switch (key) { case RedDotKey.Task: case RedDotKey.Warehouse: case RedDotKey.Shopping: case RedDotKey.ManorDecorate: case RedDotKey.Order: UpdateRedDot(RedDotKey.Manor); break; default: break; } }
/// <summary> /// 添加开关红点回调 /// </summary> /// <param name="key"></param> /// <param name="openAction"></param> static void AddOpenDotAction(RedDotKey key, Func <bool> openAction) { if (_redOpenDotActionDic.ContainsKey(key)) { _redOpenDotActionDic[key] = openAction; } else { _redOpenDotActionDic.Add(key, openAction); } }
/// <summary> /// 添加回调 /// </summary> /// <param name="redDotKey">key</param> /// <param name="action">回调</param> static void AddAction(RedDotKey redDotKey, Action action) { if (_redDotActionDic.ContainsKey(redDotKey)) { _redDotActionDic[redDotKey] = action; } else { _redDotActionDic.Add(redDotKey, action); } }
/// <summary> /// 添加对应红点 /// </summary> /// <param name="key"></param> /// <param name="tage"></param> public static void AddDotTra(RedDotKey key, Transform tage) { if (_redDotTraDic.ContainsKey(key)) { _redDotTraDic[key] = tage; } else { _redDotTraDic.Add(key, tage); } }