public ChatCellStruct(UIMessageChatCell _cell, SockWorldChatData _data, ChatCellType _celltype, int _index) { _UIMessageChatCell = _cell; _SockWorldChatData = _data; _ChatCellType = _celltype; _IndexLabel = _index; }
//时时创建UI cell void ChatCellUpdata() { int count = mChatArray.Count; for (int i = 0; i < count; i++) { if (mChatCellStructList.Count > _MaxNum) { mChatCellStructList.Dequeue()._UIMessageChatCell.dealloc(); } SockWorldChatData _tempdata = mChatArray.Dequeue(); ChatCellStruct _ChatCellStruct; if (CheckNormalOrVideo(_tempdata.content)) { _ChatCellStruct = new ChatCellStruct(CreateMessageChatCell(), _tempdata, ChatCellType.ChatCellType_NORMAL, _NowCount); } else { _ChatCellStruct = new ChatCellStruct(CreateMessageChatCell(), _tempdata, ChatCellType.ChatCellType_VIDEO, _NowCount); } _ChatCellStruct._UIMessageChatCell.OnShow(_ChatCellStruct._SockWorldChatData, _ChatCellStruct._ChatCellType); mChatCellStructList.Enqueue(_ChatCellStruct); } }
//聊天Cell的队列管理 时时创建更新 void AddChatArray(SockWorldChatData data) { if (mChatArray.Count > 29) { for (int i = 29; i < mChatArray.Count; i++) { mChatArray.Dequeue(); } } mChatArray.Enqueue(data); }
//缓存聊天列表用于没打开UI情况 void CacheChatList() { int count = mChatArray.Count; for (int i = 0; i < count; i++) { if (mChatCellStructList.Count > _MaxNum) { mChatCellStructList.Dequeue()._UIMessageChatCell.dealloc(); } SockWorldChatData _tempdata = mChatArray.Dequeue(); if (CheckNormalOrVideo(_tempdata.content)) { mChatCellStructList.Enqueue(new ChatCellStruct(CreateMessageChatCell(), _tempdata, ChatCellType.ChatCellType_NORMAL, _NowCount)); } else { mChatCellStructList.Enqueue(new ChatCellStruct(CreateMessageChatCell(), _tempdata, ChatCellType.ChatCellType_VIDEO, _NowCount)); } // _NowCount++; } }
public void OnShow(SockWorldChatData data, ChatCellType _type) { m_type = _type; gid = data.roleid; if (_type == ChatCellType.ChatCellType_NORMAL) { mNormalType.gameObject.SetActive(true); mVideoType.gameObject.SetActive(false); int m_hight = mNormalDis.height; mName.text = data.roleName; mNormalDis.SetText(data.content); mLevel.text = data.rolelv.ToString(); BgBig.height = BgBig.height + mNormalDis.height - m_hight; BgSmall.height = BgSmall.height + mNormalDis.height - m_hight; BoxCollider box1 = this.gameObject.GetComponent <BoxCollider>(); box1.size = new Vector3(BgBig.width, BgBig.height, 0f); box1.center = new Vector3(0, -(mNormalDis.height - m_hight) / 2, 0f); } else { mNormalType.gameObject.SetActive(false); mVideoType.gameObject.SetActive(true); // mVideoDis.gameObject.SetActive(false); int m_hight = mVideoDis.height; mName.text = data.roleName; mVideoDis.SetText(data.content); mLevel.text = data.rolelv.ToString(); BgBig.height = BgBig.height + mVideoDis.height - m_hight; BgSmall.height = BgSmall.height + mVideoDis.height - m_hight; BoxCollider box1 = this.gameObject.GetComponent <BoxCollider>(); box1.size = new Vector3(BgBig.width, BgBig.height, 0f); box1.center = new Vector3(0, -(mVideoDis.height - m_hight) / 2, 0f); AnalysisString(data.content); } if (data.iconid == 0) { AtlasMgr.mInstance.SetHeadSprite(mHead, "10104"); } else { AtlasMgr.mInstance.SetHeadSprite(mHead, data.iconid.ToString()); } DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); long lTime = data.time * 10000; // TimeSpan toNow = new TimeSpan(lTime+dtStart.Ticks); DateTime dt = new DateTime(lTime + dtStart.Ticks); // long time_JAVA_Long = data.time;//java长整型日期,毫秒为单位 // DateTime dt_1970 = new DateTime(1970,1,1); // long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度 // long time_tricks = tricks_1970 + time_JAVA_Long*10000;//日志日期刻度 // DateTime dt = new DateTime(time_tricks);//转化为DateTime mTime.text = dt.Year + "/" + dt.Month + "/" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second; }