/// <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); }
//推送谈判内容到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(); }
void AddToCache(TDBaseAlertData alert) { if (!CachesAlert.ContainsKey(alert.TDID)) { CachesAlert.Add(alert.TDID, new List <TDBaseAlertData>()); } CachesAlert[alert.TDID].Add(alert); }
//计算对方的接受度 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()); }
void RemoveAlert(TDBaseAlertData alert) { BaseAlertItem tempAlert = ActiveItems.Find((x) => { return(x.DataIndex == alert.ID); }); if (tempAlert == null) { return; } tempAlert.Show(false); ActiveItems.Remove(tempAlert); }
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); }
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); }
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); }
public virtual void OnAccept(TDBaseAlertData data, bool b) { Callback_OnAccept?.Invoke(data, b); }
private void OnAlertAdded(TDBaseAlertData arg1) { AddAlert(arg1); }
private void OnAlertRemoved(TDBaseAlertData arg1) { RemoveAlert(arg1); }
private void OnAlertMerge(TDBaseAlertData arg1) { }
private void OnAlertCommingTimeOut(TDBaseAlertData arg1) { throw new NotImplementedException(); }