using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PvpInvateRoot : MonoBehaviour { public static PvpInvateRoot Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } private void OnEnable() { ShowDefault(); } public void ShowDefault() { OnMenuItemClick(0); } public UIContainerBase _TeamInfoContainer; private int _HandleType = -1; public List _MarkIconList; public void OnMenuItemClick(int index) { if (index == 0) { ReqFriend(); _HandleType = (int)CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM.HANDLE_TYPE.TeamInfo; } else if(index == 1) { ReqGuild(); _HandleType = (int)CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM.HANDLE_TYPE.GuildInfo; }else { ReqNearBy(); _TeamInfoContainer.InitContentItem(null); } for(int markIndex = 0; markIndex < _MarkIconList.Count; markIndex++) { _MarkIconList[markIndex].SetActive(markIndex == index); } } static int _ReqFriendIdx = 0; private List _FriendTeamInfo = new List(); public void ReqFriend() { //发送给服务器请求 CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM packet = (CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM); packet.Ophandle = 1; packet.HandleType = (int)CG_REQ_FRIEND_INFO_WHO_IS_NOT_IN_TEAM.HANDLE_TYPE.TeamInfo; packet.SendPacket(); _FriendTeamInfo.Clear(); _TeamInfoContainer.InitContentItem(null); } public void ReqGuild() { CG_GUILD_REQ_INFO req = (CG_GUILD_REQ_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_INFO); req.SetReqType(2); req.SendPacket(); _FriendTeamInfo.Clear(); _TeamInfoContainer.InitContentItem(null); } public void ReqNearBy() { ReqGetHonorBattleFieldMatchNearPlayerList req = new ReqGetHonorBattleFieldMatchNearPlayerList(); req.Flag = 1; req.SendMsg(); } public void UpdateNearbyList(RespHonorBattleFieldMatchNearPlayerList packet) { _FriendTeamInfo.Clear(); for (int index = 0; index < packet.PlayerList.Count; index++) { PvpInvateItemStruct team = new PvpInvateItemStruct(); team._Guid = (ulong)packet.PlayerList[index].Guid; team._Name = packet.PlayerList[index].Name; team._Level = packet.PlayerList[index].Level; team._Profession = packet.PlayerList[index].Job; _FriendTeamInfo.Add(team); } _TeamInfoContainer.InitContentItem(_FriendTeamInfo); } public void UpdateTeamInfo(GC_ACK_FRIEND_INFO_WHO_IS_NOT_IN_TEAM packet) { if (packet.HandleType != _HandleType) return; PvpInvateItemStruct team = new PvpInvateItemStruct(); team._Guid = packet.Guid; team._Name = packet.Name; team._Level = packet.Level; team._Profession = packet.Prof; _FriendTeamInfo.Add(team); _TeamInfoContainer.InitContentItem(_FriendTeamInfo); } public void UpdateGuildTeamInfo(GC_GUILD_RET_INFO packet) { _FriendTeamInfo.Clear(); for (int index = 0; index < packet.memberInfoCount; index++) { if(packet.memberInfoList[index].Guid != GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid && packet.memberInfoList[index].OnlineState == 1) { if(GameManager.gameManager.PlayerDataPool.IsHaveTeam() && GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberByguiId(packet.memberInfoList[index].Guid) != null) { continue; } PvpInvateItemStruct team = new PvpInvateItemStruct(); team._Guid = packet.memberInfoList[index].Guid; team._Name = packet.memberInfoList[index].Name; team._Level = packet.memberInfoList[index].Level; team._Profession = packet.memberInfoList[index].Prof; _FriendTeamInfo.Add(team); } } _TeamInfoContainer.InitContentItem(_FriendTeamInfo); } public void OnCloseBtn() { UIManager.CloseUI(UIInfo.PvpInvateRoot); } }