Beispiel #1
0
 public void Remove(TData alert)
 {
     if (alert == null)
     {
         return;
     }
     alert.OnBeRemoved();
     Data.Remove(alert);
     if (alert.Type == AlertType.Interaction)
     {
         InteractionData.Remove(alert);
         Callback_OnInteractionChange?.Invoke(alert);
     }
     else if (alert.Type == AlertType.Disposable)
     {
         DisposableData.Remove(alert);
         Callback_DisposableChange?.Invoke(alert);
     }
     else if (alert.Type == AlertType.Continue)
     {
         ContinueData.Remove(alert);
         Callback_ContinueChange?.Invoke(alert);
     }
     //移除Article
     foreach (var item in alert.SelfArticle)
     {
         ArticleMgr.RemoveArticle(item);
     }
     foreach (var item in alert.TargetArticle)
     {
         ArticleMgr.RemoveArticle(item);
     }
     if (BaseGlobal.IsUnReadData)
     {
         Callback_OnRemoved?.Invoke(alert);
     }
 }
Beispiel #2
0
        private TData Add(string tdid, BaseUnit cast = null, Callback <TData> action = null, bool isAutoTrigger = false)
        {
            if (!TDLuaMgr.Contains(tdid))
            {
                if (CommonAlert == tdid)
                {
                    CLog.Error("没有:{0},请手动添加CommonAlert", tdid);
                }
                else
                {
                    CLog.Error("没有:{0},请手动添加Alert", tdid);
                }
                return(null);
            }

            TData sourceAlert = TDLuaMgr.Get <TData>(tdid);

            sourceAlert.Cast     = cast ? cast : LocalPlayer;
            sourceAlert.AlertMgr = this;

            //判断通知是否可以被合并
            var finalAlert = CanMerge(sourceAlert);

            if (finalAlert != null)
            {
                finalAlert.OnMerge();
                Callback_OnMerge?.Invoke(finalAlert);
            }
            else
            {
                finalAlert    = sourceAlert.Copy <TData>();
                finalAlert.ID = IDUtil.Gen();
                finalAlert.OnBeAdded(SelfBaseUnit);
                Data.Add(finalAlert);
                if (finalAlert.Type == AlertType.Interaction)
                {
                    //推送最近一次的谈判信息
                    if (ArticleMgr.IsStarNegotiation)
                    {
                        ArticleMgr.PushNagotiationToAlert(finalAlert);
                    }
                    InteractionData.Add(finalAlert);
                    Callback_OnInteractionChange?.Invoke(finalAlert);
                }
                else if (finalAlert.Type == AlertType.Disposable)
                {
                    DisposableData.Add(finalAlert);
                    Callback_DisposableChange?.Invoke(finalAlert);
                }
                else if (finalAlert.Type == AlertType.Continue)
                {
                    ContinueData.Add(finalAlert);
                    Callback_ContinueChange?.Invoke(finalAlert);
                }
                action?.Invoke(finalAlert);
                if (BaseGlobal.IsUnReadData)
                {
                    Callback_OnAdded?.Invoke(finalAlert);
                }
            }
            if (finalAlert.IsAutoTrigger || isAutoTrigger)
            {
                finalAlert.DoLeftClickTrigger();
            }
            return(finalAlert);
        }