예제 #1
0
 /// <summary>
 /// 是否可以被合并,相同的Alert将会被合并
 /// </summary>
 /// <param name="alert"></param>
 /// <returns></returns>
 private TDBaseAlertData CanMerge(TDBaseAlertData alert)
 {
     for (int i = 0; i < Data.Count; ++i)
     {
         //普通的通知id相同就合并
         if (alert.AlertType == AlertType.Normal)
         {
             if (alert.TDID == Data[i].TDID)
             {
                 return(Data[i]);
             }
         }
         //外交alert要国家相同才行
         else if (alert.AlertType == AlertType.Diplomacy)
         {
             if (alert.TDID == Data[i].TDID &&
                 alert.Cast == Data[i].Cast &&
                 alert.SelfBaseUnit == Data[i].SelfBaseUnit)
             {
                 return(Data[i]);
             }
         }
         //回信Alert不做合并
         else if (alert.AlertType == AlertType.Reply)
         {
         }
     }
     return(null);
 }
예제 #2
0
 //推送谈判内容到Alert,用于给对方发送信息
 public void PushNagotiationToAlert(TDBaseAlertData data)
 {
     if (!IsStarNegotiation)
     {
         CLog.Error("AddArticle 没有调用StarNegotiation");
         return;
     }
     data.SelfArticle.Clear();
     data.TargetArticle.Clear();
     foreach (var item in TempSelfArticlies)
     {
         item.ID         = IDUtil.Gen();
         item.BaseTarget = TargetArticleUnit;
         item.OnBeAdded(SelfArticleUnit);
         Datas.Add(item);
         data.SelfArticle.Add(item);
     }
     foreach (var item in TempTargetArticlies)
     {
         item.ID         = IDUtil.Gen();
         item.BaseTarget = SelfArticleUnit;
         item.OnBeAdded(TargetArticleUnit);
         Datas.Add(item);
         data.TargetArticle.Add(item);
     }
     data.WarfareData = CurWarData;
     clearNagotiation();
 }
예제 #3
0
 void AddToCache(TDBaseAlertData alert)
 {
     if (!CachesAlert.ContainsKey(alert.TDID))
     {
         CachesAlert.Add(alert.TDID, new List <TDBaseAlertData>());
     }
     CachesAlert[alert.TDID].Add(alert);
 }
예제 #4
0
        //计算对方的接受度
        public float CalcProp(TDBaseAlertData data)
        {
            var negotiation = GetNegotiation(data.TDID);

            if (negotiation == null)
            {
                return(0);
            }
            return(negotiation.SetParam(data.Cast as TUnit, data.SelfBaseUnit as TUnit, data.WarfareData as TWarData, data.SelfArticle, data.TargetArticle)
                   .CalcProb());
        }
예제 #5
0
        void RemoveAlert(TDBaseAlertData alert)
        {
            BaseAlertItem tempAlert = ActiveItems.Find((x) => { return(x.DataIndex == alert.ID); });

            if (tempAlert == null)
            {
                return;
            }
            tempAlert.Show(false);
            ActiveItems.Remove(tempAlert);
        }
예제 #6
0
 public void RemoveAlert(TDBaseAlertData alert)
 {
     if (alert == null)
     {
         return;
     }
     Data.Remove(alert);
     Callback_OnRemoved?.Invoke(alert);
     alert.OnBeRemoved();
     alert.OnEnd();
     AddToCache(alert);
     IDMgr.Remove(alert.ID);
 }
예제 #7
0
        void AddAlert(TDBaseAlertData alert)
        {
            GameObject    go        = GOPool.Spawn();
            BaseAlertItem alertItem = go.GetComponent <BaseAlertItem>();

            alertItem.Init(new BaseButtonData {
                IconStr = alert.Icon,
                BgStr   = alert.Bg,
                OnClick = alert.OnClick,
                OnShow  = OnAlertShow,
            });
            alertItem.Show(true);
            alertItem.RectTrans.position = StartPos.position;
            ActiveItems.Add(alertItem);
        }
예제 #8
0
        public TDBaseAlertData Add(string alertName, BaseUnit cast = null)
        {
            if (!Table.Contains(alertName))
            {
                if (CommonAlert == alertName)
                {
                    CLog.Error("请手动添加 CommonAlert");
                }
                return(null);
            }
            TDBaseAlertData tempAlert = null;

            if (IsHaveCache(alertName))
            {
                tempAlert = GetCache(alertName);
                CachesAlert.Remove(alertName);
            }
            else
            {
                tempAlert = Table.Find(alertName).Copy();
            }

            tempAlert.Cast = cast?cast:LocalPlayer;

            if (tempAlert == null)
            {
                CLog.Error("未找到alert errorId=" + alertName);
                return(null);
            }
            //判断通知是否可以被合并
            var mergeAlert = CanMerge(tempAlert);

            if (mergeAlert != null)
            {
                mergeAlert.OnMerge();
                Callback_OnMerge?.Invoke(mergeAlert);
            }
            else
            {
                tempAlert.ID = IDMgr.GetNextId();
                Data.Add(tempAlert);
                tempAlert.OnBeAdded(SelfBaseUnit);
                Callback_OnAdded?.Invoke(tempAlert);
                tempAlert.OnStart();
            }
            return(tempAlert);
        }
예제 #9
0
 public virtual void OnAccept(TDBaseAlertData data, bool b)
 {
     Callback_OnAccept?.Invoke(data, b);
 }
예제 #10
0
 private void OnAlertAdded(TDBaseAlertData arg1)
 {
     AddAlert(arg1);
 }
예제 #11
0
 private void OnAlertRemoved(TDBaseAlertData arg1)
 {
     RemoveAlert(arg1);
 }
예제 #12
0
 private void OnAlertMerge(TDBaseAlertData arg1)
 {
 }
예제 #13
0
 private void OnAlertCommingTimeOut(TDBaseAlertData arg1)
 {
     throw new NotImplementedException();
 }