public void OnNewBroadCastInfoPush(short state, NewBroadCastInfoPush down = null) { if (state != 0) { StateManager.Instance.StateShow(state, 0); return; } if (down != null) { int id = down.id; GuangBoNeiRong guangBoNeiRong = DataReader <GuangBoNeiRong> .Get(id); if (guangBoNeiRong == null) { return; } int show = guangBoNeiRong.show; switch (show) { case 0: this.AddQueue(this.ContentFormat(down)); this.BroadcastToChatManager(down); break; case 1: this.AddQueue(this.ContentFormat(down)); break; case 2: this.BroadcastToChatManager(down); break; default: Debug.LogError("不存在的显示类型:" + show); break; } } }
private void BroadcastToChatManager(NewBroadCastInfoPush down) { GuangBoNeiRong guangBoNeiRong = DataReader <GuangBoNeiRong> .Get(down.id); if (guangBoNeiRong == null) { return; } ChineseData chineseData = DataReader <ChineseData> .Get(guangBoNeiRong.desc); if (chineseData == null) { return; } if (guangBoNeiRong.hitEventId.get_Count() > 5) { return; } string text = chineseData.content; text = this.FormatDesc(text, guangBoNeiRong.hitEventId.get_Count()); this.RefreshDetailInfos(down.paramters, guangBoNeiRong.hitEventId); ChatManager.Instance.BroadcastMessageReceive(text, down.paramters); }
private string ContentFormat(NewBroadCastInfoPush down = null) { if (down == null) { return(string.Empty); } int id = down.id; GuangBoNeiRong guangBoNeiRong = DataReader <GuangBoNeiRong> .Get(id); if (guangBoNeiRong == null) { return(string.Empty); } string chineseContent = GameDataUtils.GetChineseContent(guangBoNeiRong.desc, false); if (string.IsNullOrEmpty(chineseContent)) { return(string.Empty); } List <string> list = new List <string>(); List <int> hitEventId = DataReader <GuangBoNeiRong> .Get(id).hitEventId; int count = hitEventId.get_Count(); if (count >= 1) { for (int i = 0; i < count; i++) { int type = DataReader <GuangBoLianJie> .Get(hitEventId.get_Item(i)).type; switch (type) { case 0: list.Add((i >= down.paramters.get_Count()) ? string.Empty : down.paramters.get_Item(i).label); break; case 1: list.Add((i >= down.paramters.get_Count()) ? string.Empty : down.paramters.get_Item(i).label); break; case 2: list.Add((down.paramters.get_Count() >= i) ? string.Empty : GameDataUtils.GetItemName(down.paramters.get_Item(i).cfgId, false, 0L)); break; case 3: case 4: list.Add(GameDataUtils.GetChineseContent(DataReader <GuangBoLianJie> .Get(hitEventId.get_Item(i)).name, false)); break; default: Debug.LogError(string.Concat(new object[] { "There is no hitType: ", type, " , Broadcast ID: ", id })); list.Add(string.Empty); break; } } } string result; try { if (count <= 0) { result = chineseContent; } else if (count == 1) { result = string.Format(chineseContent, list.get_Item(0)); } else if (count == 2) { result = string.Format(chineseContent, list.get_Item(0), list.get_Item(1)); } else if (count == 3) { result = string.Format(chineseContent, list.get_Item(0), list.get_Item(1), list.get_Item(2)); } else if (count == 4) { result = string.Format(chineseContent, new object[] { list.get_Item(0), list.get_Item(1), list.get_Item(2), list.get_Item(3) }); } else if (count == 5) { result = string.Format(chineseContent, new object[] { list.get_Item(0), list.get_Item(1), list.get_Item(2), list.get_Item(3), list.get_Item(4) }); } else { result = string.Empty; } } catch (Exception ex) { Debug.LogError(ex.get_Message()); Debug.LogError(string.Concat(new object[] { "广播Format出错, _id = ", id, ", desc = ", chineseContent })); result = string.Empty; } return(result); }