using UnityEngine; using UnityEngine.UI; using System.Collections; using Games.Item; using System.Collections.Generic; using GCGame.Table; using Games.GlobeDefine; public class CommunityMsgPageLogic : UIControllerBase { void OnEnable() { SetInstance(this); InitPage(); } void OnDisable() { SetInstance(null); } public void CloseWindow() { gameObject.SetActive(false); } #region public GameObject _BasePanel; public GameObject _ViewPanel; public GameObject _FlowerPanel; public void InitPage() { InitBasePanel(); } #endregion #region base public Text _ViewCnt; public Text _PresentCnt; public Text _FlowerCnt; public Button _BtnPresent; public UIContainerBlog _MsgContainer; public GameObject _OptPanel; public GameObject _LeaveMsgPanel; public Text _LeaveMsgTip; public GameObject _MyOptPanel; public GameObject _OtherOptPanel; private CommunityLeaveMsgInfo _SelectedMsg; public void InitBasePanel() { _BasePanel.SetActive(true); _ViewPanel.SetActive(false); _FlowerPanel.SetActive(false); _OptPanel.SetActive(true); _LeaveMsgPanel.SetActive(false); UpdateGiftCnts(); _SelectedMsg = null; if (CommunityLogic.CommunityPlayerInfo.GUID == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) { _MyOptPanel.SetActive(true); _OtherOptPanel.SetActive(false); _BtnPresent.gameObject.SetActive(true); } else { _MyOptPanel.SetActive(false); _OtherOptPanel.SetActive(true); _BtnPresent.gameObject.SetActive(false); } _LeaveMsgs.Clear(); _MsgContainer.InitContentItem(null); ReloadMoreMsg(); //_ViewCnt.text = "1"; //_PresentCnt.text = "2"; //_FlowerCnt.text = "3"; //List leaveMsgs = new List(); //for (int i = 0; i < 5; ++i) //{ // CommunityLeaveMsgInfo msgInfo = new CommunityLeaveMsgInfo(); // leaveMsgs.Add(msgInfo); // msgInfo.GUID = (ulong)i; // msgInfo.Profession = i; // msgInfo.Name = "FocusPlayer" + i; // msgInfo.Level = 100 + i; // msgInfo.MsgText = ""; // msgInfo.Time = i; //} //_MsgContainer.InitContentItem(leaveMsgs, OnReciveMsg); } public void UpdateGiftCnts() { _ViewCnt.text = Community.Instance._ViewCnt.ToString(); _PresentCnt.text = Community.Instance._GiftCnt.ToString(); _FlowerCnt.text = Community.Instance._FlowerCnt.ToString(); } public void OnReciveMsg(object msgObj) { CommunityLeaveMsgInfo msgInfo = msgObj as CommunityLeaveMsgInfo; if (msgInfo == null) return; _SelectedMsg = msgInfo; OnBtnShowLeaveMsg(); _LeaveMsgTip.text = StrDictionary.GetClientDictionaryString("#{39006}", msgInfo.Name); } public void OnLeaveWord(string leaveWord) { CG_REQ_LEAVE_WORD packet = (CG_REQ_LEAVE_WORD)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_LEAVE_WORD); packet.Roleguid = CommunityLogic.CommunityPlayerInfo.GUID; packet.Msg = leaveWord; if (_SelectedMsg != null) { packet.Targetguid = _SelectedMsg.GUID; } else { packet.Targetguid = GlobeVar.INVALID_GUID; } packet.SendPacket(); } public void OnBtnShowLeaveMsg() { _OptPanel.SetActive(false); _LeaveMsgPanel.SetActive(true); } public void OnBtnShowOptPanel() { _OptPanel.SetActive(true); _LeaveMsgPanel.SetActive(false); _SelectedMsg = null; } public void OnViewSpace() { CG_REQ_STEP_SPACE packet = (CG_REQ_STEP_SPACE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_STEP_SPACE); packet.Roleguid = CommunityLogic.CommunityPlayerInfo.GUID; packet.SendPacket(); } public void OnSendFlower() { CommunityGiveFlowerLogic.GiveFlower(CommunityLogic.CommunityPlayerInfo.GUID, CommunityLogic.CommunityPlayerInfo.Name); //CommunityLogic.Instance()._GiveFlowerPanel.ShowWindow(); } #endregion #region load msg private int _LastLoadMsgIDX = -1; private List _LeaveMsgs = new List(); private static int _ReloadMsg = 10; public void LoadMoreMsg() { CG_REQ_VIEW_LEAVE_WORD_LIST packet = (CG_REQ_VIEW_LEAVE_WORD_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_LEAVE_WORD_LIST); packet.Roleguid = CommunityLogic.CommunityPlayerInfo.GUID; packet.Curindex = _LastLoadMsgIDX; packet.Targetindex = _LastLoadMsgIDX; packet.Count = _ReloadMsg; packet.SendPacket(); } public void ReloadMoreMsg() { _LastLoadMsgIDX = -1; _LeaveMsgs.Clear(); LoadMoreMsg(); } public void RetLoadMsg(GC_RET_VIEW_LEAVE_WORD_LIST packet) { for (int i = 0; i < packet.roleguidlistCount; ++i) { CommunityLeaveMsgInfo msgInfo = new CommunityLeaveMsgInfo(); _LeaveMsgs.Add(msgInfo); msgInfo.MsgIDX = packet.GetIndexlist(i); msgInfo.GUID = packet.GetRoleguidlist(i); msgInfo.HeadIconName = packet.GetHeadpiclist(i); msgInfo.Name = packet.GetNamelist(i); msgInfo.Level = packet.GetLevellist(i); msgInfo.MsgText = packet.GetLeavewordlist(i); msgInfo.Time = packet.GetRecordtimelist(i); msgInfo.TargetGUID = packet.GetTargetguidlist(i); msgInfo.TargetName = packet.GetTargetnamelist(i); msgInfo.Profession = packet.GetJoblist(i); _LastLoadMsgIDX = msgInfo.MsgIDX; } if (packet.roleguidlistCount == 0) { if (_LeaveMsgs.Count > _ReloadMsg) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{39013}")); } _MsgContainer.IsLoadAllItems = true; } _MsgContainer.InitContentItem(_LeaveMsgs, OnReciveMsg); if (_LeaveMsgs.Count > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{39018}"); } } #endregion #region viewer panel public UIContainerBase _ViewContainer; public void InitViewPanel() { _BasePanel.SetActive(false); _ViewPanel.SetActive(true); _FlowerPanel.SetActive(false); LoadMoreViewHis(); //List players = new List(); //for (int i = 0; i < 4; ++i) //{ // CommunityOtherPlayerInfo playerInfo = new CommunityOtherPlayerInfo(); // players.Add(playerInfo); // playerInfo.Profession = i; // playerInfo.Name = "FocusPlayer" + i; // playerInfo.Level = 100 + i; //} //_ViewContainer.InitContentItem(players); //CommunityLogic.Instance()._EmptyTip.text = ""; } public void LoadMoreViewHis() { CG_REQ_VIEW_STEP_SPACE_HISTORY packet = (CG_REQ_VIEW_STEP_SPACE_HISTORY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_STEP_SPACE_HISTORY); packet.Roleguid = CommunityLogic.CommunityPlayerInfo.GUID; packet.SendPacket(); } public void RetLoadViewHis(GC_RET_VIEW_STEP_SPACE_HISTORY packet) { List players = new List(); for (int i = 0; i < packet.roleguidlistCount; ++i) { CommunityOtherPlayerInfo playerInfo = new CommunityOtherPlayerInfo(); players.Add(playerInfo); playerInfo.Level = packet.GetLevellist(i); playerInfo.HeadIconName = packet.GetHeadpiclist(i); playerInfo.Profession = packet.GetJoblist(i); playerInfo.Name = packet.GetRolename(i); playerInfo.GUID = packet.GetRoleguidlist(i); } _ViewContainer.InitContentItem(players); if (players.Count > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{39015}"); } } public void BackToBase() { _BasePanel.SetActive(true); _ViewPanel.SetActive(false); _FlowerPanel.SetActive(false); if (_LeaveMsgs.Count > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{39018}"); } } #endregion #region public UIContainerBase _FlowerContainer; private int _LastFlowerHisIdx; private List _FlowerHisList = new List(); public void InitFlowerPanel() { _BasePanel.SetActive(false); _ViewPanel.SetActive(false); _FlowerPanel.SetActive(true); ReloadFlowerHis(); //List players = new List(); //for (int i = 0; i < 4; ++i) //{ // CommunityFlowerInfo playerInfo = new CommunityFlowerInfo(); // players.Add(playerInfo); // playerInfo.Profession = i; // playerInfo.Name = "FocusPlayer" + i; // playerInfo.Level = 100 + i; // playerInfo.Time = i * 1000; // playerInfo.Flower1 = i; // playerInfo.Flower2 = i; // playerInfo.Flower3 = i; // playerInfo.Flower4 = i; // playerInfo.FlowerTotal = i*10; //} //_FlowerContainer.InitContentItem(players); //CommunityLogic.Instance()._EmptyTip.text = ""; } public void LoadMoreFlowerHis() { CG_REQ_VIEW_GIVE_FLOWER_HISTORY packet = (CG_REQ_VIEW_GIVE_FLOWER_HISTORY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_GIVE_FLOWER_HISTORY); packet.Roleguid = CommunityLogic.CommunityPlayerInfo.GUID; packet.Curindex = _LastFlowerHisIdx; packet.Count = 10; packet.SendPacket(); } public void ReloadFlowerHis() { _LastFlowerHisIdx = -1; _FlowerHisList.Clear(); LoadMoreFlowerHis(); } public void RetFlowerHis(GC_RET_VIEW_GIVE_FLOWER_HISTORY packet) { if (!_FlowerPanel.activeSelf) return; for (int i = 0; i < packet.indexCount; ++i) { CommunityFlowerInfo playerInfo = new CommunityFlowerInfo(); _FlowerHisList.Add(playerInfo); playerInfo.HeadIconName = packet.GetRoleheadpiclist(i); playerInfo.Profession = packet.GetJoblist(i); playerInfo.Name = packet.GetRolenamelist(i); playerInfo.GUID = packet.GetRoleguidlist(i); playerInfo.Level = packet.GetRolelevellist(i); playerInfo.Time = packet.GetLastrecordtime(i); for (int j = 0; j < packet.GetGiveflowerinfolist(i).countCount; ++j) { playerInfo.SetFlowerCnt(packet.GetGiveflowerinfolist(i).GetItemid(j), packet.GetGiveflowerinfolist(i).GetCount(j)); } playerInfo.FlowerTotal = packet.GetFriendly(i); _LastFlowerHisIdx = packet.GetIndex(i); } _FlowerContainer.InitContentItem(_FlowerHisList); if (_FlowerHisList.Count > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{39016}"); } } #endregion }