using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class FriendTips : MonoBehaviour { [SerializeField] ScrollerController typeCtrl; [SerializeField] Button searchBtn; [SerializeField] GameObject searchBackIcon; [SerializeField] InputField inputField; [SerializeField] GameObject searchObj; [SerializeField] PlayerInfoCell playerInfoCell; [SerializeField] GameObject contactlistObj; [SerializeField] Button recommendBtn; [SerializeField] GameObject chatSendObj; [SerializeField] ChatContentBehaviour chatBeh; [SerializeField] Text speakOtherNameText; [SerializeField] GameObject selectFriendObj; [SerializeField] GameObject unSelectFriendObj; List typelist = new List(); public static GroupType lookGroupType = GroupType.None; public static int selectPlayerId = 0; Dictionary lookPlayerInfoDict = null; FriendsModel _friendsModel; FriendsModel friendsModel { get { return _friendsModel ?? (_friendsModel = ModelCenter.Instance.GetModel()); } } private void Awake() { typeCtrl.OnRefreshCell += RefreshCell; typelist.Clear(); typelist.Add(GroupType.RecentContact); typelist.Add(GroupType.Friend); typelist.Add(GroupType.Enemy); typelist.Add(GroupType.Balcklist); } private void OnEnable() { speakOtherNameText.text = ""; friendsModel.RefreshFriendModel += RefreshFriendInfo; friendsModel.RefreshFriendCntEvent += RefreshFriendCnt; ChatCtrl.Inst.presentChatType = ChatInfoType.Friend; chatBeh.chatType = ChatInfoType.Friend; lookPlayerInfoDict = null; lookGroupType = GroupType.None; CreateCell(); friendsModel.OnSendCA9A3_tagCGQueryRecommendFriends(); searchBtn.AddListener(ClickSearchBtn); recommendBtn.AddListener(ClickRecommendBtn); searchObj.SetActive(false); contactlistObj.SetActive(true); searchBackIcon.SetActive(false); } private void OnDisable() { friendsModel.RefreshFriendModel -= RefreshFriendInfo; friendsModel.RefreshFriendCntEvent -= RefreshFriendCnt; recommendBtn.RemoveAllListeners(); searchBtn.RemoveAllListeners(); lookGroupType = GroupType.None; selectPlayerId = 0; } private void RefreshFriendInfo() { CreateCell(); } private void RefreshFriendCnt(GroupType type, bool addFriendPlayer) { CreateCell(); } private void CreateCell() { typeCtrl.Refresh(); lookPlayerInfoDict = null; for (int i = 0; i < typelist.Count; i++) { typeCtrl.AddCell(ScrollerDataType.Header,i); if(lookGroupType == typelist[i]) { lookPlayerInfoDict = friendsModel.GetFriendInfoDict((byte)lookGroupType); if(lookPlayerInfoDict != null) { foreach (var id in lookPlayerInfoDict.Keys) { typeCtrl.AddCell(ScrollerDataType.Normal, (int)id); } } } } typeCtrl.Restart(); if(selectPlayerId != 0) { selectFriendObj.SetActive(true); unSelectFriendObj.SetActive(false); } else { selectFriendObj.SetActive(false); unSelectFriendObj.SetActive(true); ChatCtrl.Inst.PteChatID = 0; ChatCtrl.Inst.PteChatName = string.Empty; LanguageVerify.toPlayerLevel = 0; } } private void RefreshCell(ScrollerDataType type, CellView cell) { switch (type) { case ScrollerDataType.Header: GroupType groupType = typelist[cell.index]; ContactType contactType = cell.GetComponent(); Button typeBtn = cell.GetComponent