private void RemovChat(UInt64 arg1) { GameObject tempObj = null; if (arg1 == 0) { return; } ClearOld(); if (TalkChatName.TryGetValue(arg1, out tempObj)) { if (TalkChatName.Count <= 0) { mLastTemp = 0; mLastObj = null; } else { mLastTemp = TalkChatName.ElementAt(0).Key; mLastObj = TalkChatObj[TalkChatName.ElementAt(0).Value]; if (TalkChatObj.ContainsKey(tempObj)) { UnityEngine.GameObject.DestroyImmediate(TalkChatObj[tempObj].objParent); TalkChatObj[tempObj] = null; TalkChatObj.Remove(tempObj); } } Refresh(); TalkChatName[arg1] = null; TalkChatName.Remove(arg1); mChatTaskNameGrid.repositionNow = true; mChatTaskNameGrid.Reposition(); } }
private void CloseChatPress(GameObject go) { mLastObj = null; TalkChatName.Clear(); TalkChatObj.Clear(); ChatTaskCtrl.Instance.Exit(); }
//窗口控件初始化 protected override void InitWidget() { mLastObj = null; CloseChat = mRoot.Find("CloseBtn").gameObject; MsgInfo = mRoot.Find("ChatWindow/InputArea").GetComponent <UIInput>(); SendMsgInfo = mRoot.Find("ChatWindow/SendMSg").gameObject; mChatTaskNameGrid = mRoot.Find("ChatList/Panel/Grid").GetComponent <UIGrid>(); TalkTable = mRoot.Find("ChatWindow/Scroll View/Table").GetComponent <UITable>(); ScrollView = mRoot.Find("ChatWindow/Scroll View").GetComponent <UIScrollView>(); ScrollBar = mRoot.Find("ChatWindow/Control - Simple Vertical Scroll Bar").GetComponent <UIScrollBar>(); ScrollMemBer = mRoot.Find("ChatList/Control - Simple Vertical Scroll Bar").GetComponent <UIScrollBar>(); UIEventListener.Get(CloseChat).onClick += CloseChatPress; UIEventListener.Get(SendMsgInfo).onClick += SendChatPress; bool isTure = false; if (mLastObj != null || FriendManager.Instance.AllTalkDic.Count < 1) { CreateMember(mLastTemp); } else { foreach (var item in FriendManager.Instance.AllTalkDic.Values) { if (item.SGUID == mLastTempNew) { isTure = true; continue; } GameObject gameObj = null; if (item.NickName == null && string.IsNullOrEmpty(item.NickName)) { continue; } if (TalkChatName.TryGetValue(item.SGUID, out gameObj)) { if (IsVisable && TalkChatObj.ContainsKey(gameObj)) { TalkChatObj[gameObj].mTwinkle.SetActive(true); } continue; } if (item.TalkState == MsgTalkEnum.UnReadMsg) { isReadInfo = false; } else { isReadInfo = true; } CreateMember(item.SGUID); } if (mLastTempNew != 0 && (isTure || !FriendManager.Instance.AllTalkDic.ContainsKey(mLastTempNew))) { isReadInfo = true; CreateMember(mLastTempNew); } ChatTaskCtrl.Instance.SetNewChat(); } }
void CreateMember(UInt64 temp) { if (mChatTaskNameGrid.transform.childCount <= 0) { EventDelegate.Add(ScrollBar.onChange, OnScrollBarChange); } if (temp == 0) { return; } Friend friend = null; if (FriendManager.Instance.AllFriends.TryGetValue(temp, out friend)) { ResourceItem objUnit = ResourcesManager.Instance.loadImmediate(GameConstDefine.LoadChatMember, ResourceType.PREFAB); GameObject obj = GameObject.Instantiate(objUnit.Asset) as GameObject; obj.transform.parent = mChatTaskNameGrid.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; ChatNameMember chat = new ChatNameMember(); chat.mNickName = obj.transform.Find("Name").GetComponent <UILabel>(); chat.mHighlight = obj.transform.Find("Highlight").gameObject; chat.mTwinkle = obj.transform.Find("Twinkle").gameObject; chat.mNickName.text = friend.NiceName; chat.sGUID = temp; chat.objParent = obj; chat.mTwinkle.gameObject.SetActive(!isReadInfo); if (mLastObj == null && (mLastTempNew == temp || mLastTempNew == 0)) { mLastObj = chat; mLastTemp = temp; chat.mHighlight.SetActive(true); chat.mTwinkle.gameObject.SetActive(false); ClearOld(); } if (!TalkChatName.ContainsKey(temp)) { TalkChatName.Add(temp, obj); } if (!TalkChatObj.ContainsKey(obj)) { TalkChatObj.Add(obj, chat); } UIEventListener.Get(obj).onClick += ChatNameSelect; mChatTaskNameGrid.repositionNow = true; mChatTaskNameGrid.Reposition(); ScrollBar.value = 1f; } }
private void ChatNameSelect(GameObject go) { if (mLastObj != null && mLastObj.objParent == go) { return; } if (mLastObj != null) { mLastObj.mHighlight.SetActive(false); } if (TalkChatObj.TryGetValue(go, out mLastObj)) { mLastObj.mHighlight.SetActive(true); mLastObj.mTwinkle.SetActive(false); mLastTemp = mLastObj.sGUID; } ClearOld(); Refresh(); }
bool isCreate(UInt64 temp) { GameObject gameObj = null; if (temp == 0) { return(false); } if (TalkChatName.TryGetValue(temp, out gameObj)) { if (IsVisable && TalkChatObj.ContainsKey(gameObj)) { TalkChatObj[gameObj].mTwinkle.SetActive(true); } return(false); } //if (mLastObj != null && IsVisable) //{ // mLastObj.mHighlight.SetActive(false); // mLastObj = null; //} return(true); }