void Awake() { Button_OpenWorldPanel.SetCallBackFuntion(OpenWorldPanel, null); Button_Send.SetCallBackFuntion(SendChat, null); //TODO GuideBtnManager.Instance.RegGuideButton(Button_OpenWorldPanel.gameObject, UIType.Chat, SubType.ButtomCommon, out m_guideBtnID); RegisterEventHandler(); //初始化 m_buttonsDict.Add(WindowType.Town, Button_Town); m_buttonsDict.Add(WindowType.World, Button_World); m_buttonsDict.Add(WindowType.System, Button_System); m_buttonsDict.Add(WindowType.Team, Button_Team); //初始化私聊窗口 ChatRecordManager.Instance.GetPrivateChatRecordDict().ApplyAllItem(p => { GameObject talker = UI.CreatObjectToNGUI.InstantiateObj(TalkerItemPrefab, TitlePoint); PrivateTalkerItem privateTalkerItem = talker.GetComponent <PrivateTalkerItem>(); string talkerName = ""; if (p.Value[0].SenderName == PlayerManager.Instance.FindHeroDataModel().Name) { talkerName = p.Value[0].AccepterName; } else { talkerName = p.Value[0].SenderName; } privateTalkerItem.Init(p.Value[0].L_ChaterID, talkerName); m_privateTalkerDict.Add(p.Value[0].L_ChaterID, privateTalkerItem); InitPrivateWindow(p.Value[0].L_ChaterID, ChatRecordManager.Instance.GetPrivateChatRecordList(p.Value[0].L_ChaterID)); //开启未读动画提示 m_privateTalkerDict[p.Value[0].L_ChaterID].ShowNewTip(); }); int index = 0; m_privateTalkerDict.ApplyAllItem(p => { p.Value.transform.localPosition = Vector3.right * SPACING_TITLE_BUTTON * index; index++; }); Button_Close.SetCallBackFuntion(OnCloseClick, null); Button_Town.SetCallBackFuntion(OnTownClick, null); Button_World.SetCallBackFuntion(OnWorldClick, null); Button_System.SetCallBackFuntion(OnSystemClick, null); Button_Team.SetCallBackFuntion(OnTeamClick, null); Button_PageUp.SetCallBackFuntion(OnPageUpClick, null); Button_PageDown.SetCallBackFuntion(OnPageDownClick, null); TitleInitialPos = TitlePoint.transform.localPosition; }
//切换私聊窗口 private void SwitchingPrivateWindow(int chaterID, string chaterName) { m_curWindowType = WindowType.Private; iTalkToWorldID = (uint)chaterID; if (!m_privateTalkerDict.ContainsKey(chaterID)) { //初始化 GameObject talker = UI.CreatObjectToNGUI.InstantiateObj(TalkerItemPrefab, TitlePoint); PrivateTalkerItem privateTalkerItem = talker.GetComponent <PrivateTalkerItem>(); privateTalkerItem.Init(chaterID, chaterName); m_privateTalkerDict.Add(chaterID, privateTalkerItem); int index = 0; m_privateTalkerDict.ApplyAllItem(p => { p.Value.transform.localPosition = Vector3.right * SPACING_TITLE_BUTTON * index; index++; }); // for(int i=0;i<m_privateTalkerDict.Count;i++) // { // m_privateTalkerDict[i].transform.localPosition = Vector3.right * SPACING_TITLE_BUTTON * i; // } InitPrivateWindow(chaterID, ChatRecordManager.Instance.GetPrivateChatRecordList(chaterID)); } m_privateTalkerDict.ApplyAllItem(p => { if (p.Key == chaterID) { p.Value.Show(true); m_privateWindowDict[p.Key].Show(); } else { p.Value.Show(false); m_privateWindowDict[p.Key].Close(); } }); //关闭私信提醒 // if(!m_privateTalkerDict.Values.Any(p=>p.IsHasNewMessage)) // { // UIEventManager.Instance.TriggerUIEvent(UIEventType.ClosePrivateMessageTip,null); // } if (ChatPanel.transform.localPosition == Vector3.zero && m_curWindowType == WindowType.Private) { UIEventManager.Instance.TriggerUIEvent(UIEventType.ClosePrivateMessageTip, null); } Speaker.SetActive(false); Button_Send.gameObject.SetActive(true); Input_Chat.gameObject.SetActive(true); UpdatePageButtons(false); }
//接收私信 void ReceiveChatMsgHandle(object obj) { SMsgChat_SC sMsgChat_SC = (SMsgChat_SC)obj; if (m_privateWindowDict.ContainsKey(sMsgChat_SC.L_ChaterID)) { m_privateWindowDict[sMsgChat_SC.L_ChaterID].AddChat(sMsgChat_SC); } else { //初始化 GameObject talker = UI.CreatObjectToNGUI.InstantiateObj(TalkerItemPrefab, TitlePoint); PrivateTalkerItem privateTalkerItem = talker.GetComponent <PrivateTalkerItem>(); privateTalkerItem.Init(sMsgChat_SC.L_ChaterID, sMsgChat_SC.SenderName); m_privateTalkerDict.Add(sMsgChat_SC.L_ChaterID, privateTalkerItem); int index = 0; m_privateTalkerDict.ApplyAllItem(p => { p.Value.transform.localPosition = Vector3.right * SPACING_TITLE_BUTTON * index; index++; }); InitPrivateWindow(sMsgChat_SC.L_ChaterID, ChatRecordManager.Instance.GetPrivateChatRecordList(sMsgChat_SC.L_ChaterID)); if (m_curWindowType != WindowType.Private) { talker.SetActive(false); } } //开启未读动画提示 if (transform.localPosition != Vector3.zero || sMsgChat_SC.L_ChaterID != iTalkToWorldID) { m_privateTalkerDict[sMsgChat_SC.L_ChaterID].ShowNewTip(); } //关闭私信提醒 // if(ChatPanel.transform.localPosition == Vector3.zero && !m_privateTalkerDict.Values.Any(p=>p.IsHasNewMessage)) // { // UIEventManager.Instance.TriggerUIEvent(UIEventType.ClosePrivateMessageTip,null); // } if (transform.localPosition == Vector3.zero && m_curWindowType == WindowType.Private) { UIEventManager.Instance.TriggerUIEvent(UIEventType.ClosePrivateMessageTip, null); } else { UIEventManager.Instance.TriggerUIEvent(UIEventType.ShowPrivateMessageTip, null); } }