/// <summary> /// 获取其他玩家的信息 /// </summary> /// <param name="id"></param> private void GetShipData(ulong id) { //Debug.LogError("收到玩家信息"+id); ShipItemsProxy shipItemsProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipItemsProxy) as ShipItemsProxy; // 飞船的 IShip ship = shipItemsProxy.GetCurrentWarShip(id); if (ship != null) { FriendInfoVO vO = m_FriendProxy.GetFriend(id); if (vO != null) { MsgPlayerInfo msgPlayerInfo = new MsgPlayerInfo(); msgPlayerInfo.Name = vO.Name; msgPlayerInfo.Tid = vO.TID; msgPlayerInfo.UID = vO.UID; msgPlayerInfo.Ship = ship; m_LeftSelectIndex = (int)m_SocialSubClass; //OwnerView.OpenChildPanel(UIPanel.EscWatchPanel, msgPlayerInfo); } } else { Debug.Log("船的信息为空"); } }
/// <summary> /// 打开Tip /// </summary> private void OpenTip(FriendInfoVO data) { if (m_TipPrefab) { if (!m_TipInstance1) { m_TipInstance1 = m_TipPrefab.Spawn(TipBoxLeft); m_TipInstance1.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; } LayoutFriendTip(m_TipInstance1, data); } else if (!m_TipPrefabLoading) { m_TipPrefabLoading = true; LoadPrefabFromPool(TIP_PREFAB, (prefab) => { if (Opened) { m_TipPrefab = prefab; OpenTipView(); } }); } }
/// <summary> /// 填充好友数据 /// </summary> public void SetFriendData(FriendInfoVO infoVO, UISocialList.SocialType socialType) { if (infoVO.UID > 0) { m_NullElelment.gameObject.SetActive(false); m_Elelment.gameObject.SetActive(true); m_SocialType = socialType; SetContent(); m_LevelText.text = string.Format(TableUtil.GetLanguageString("character_text_1019"), infoVO.Level.ToString()); m_PlayerName.text = infoVO.Name; if (infoVO.TID > 0) { if (m_CfgEternityProxy.GetPlayerByItemTId(infoVO.TID) != null) { UIUtil.SetIconImage(m_HeardImage, (uint)m_CfgEternityProxy.GetPlayerByItemTId(infoVO.TID).Value.HeadPortrait); } } if (infoVO.Status == FriendInfoVO.FriendState.ONLINE) { m_OnLineImage.gameObject.SetActive(true); } } else { m_NullElelment.gameObject.SetActive(true); m_Elelment.gameObject.SetActive(false); } }
/// <summary> /// 改变成员 /// </summary> public void SetMember(ulong id, bool isOnline) { FriendInfoVO member = GetFriend(id); if (member != null) { member.Status = isOnline? FriendInfoVO.FriendState.ONLINE: FriendInfoVO.FriendState.LEAVE; GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_LIST_CHANGED, member); } }
protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); Animator animator = cellView.GetComponent <Animator>(); RectTransform content = FindComponent <RectTransform>(cellView, "Content"); if (animator) { animator.SetBool("IsOn", selected); } int page = groupIndex; int index = cellIndex; ulong infoVOId = 0; SocialElement m_SocialElement = cellView.GetComponent <SocialElement>(); if (m_SocialElement == null) { m_SocialElement = cellView.gameObject.AddComponent <SocialElement>(); m_SocialElement.Initialize(); } switch (m_SocialType) { case SocialType.Team: TeamMemberVO teamMemberVO = cellData as TeamMemberVO; m_SocialElement.SetTeamData(teamMemberVO, m_SocialType, new Vector2Int(groupIndex, cellIndex)); infoVOId = teamMemberVO.UID; break; case SocialType.Friend: FriendInfoVO friendInfoVO = cellData as FriendInfoVO; m_SocialElement.SetFriendData(friendInfoVO, m_SocialType); infoVOId = friendInfoVO.UID; break; case SocialType.Ship: FriendInfoVO Ship = cellData as FriendInfoVO; m_SocialElement.SetFriendData(Ship, m_SocialType); infoVOId = Ship.UID; break; case SocialType.Other: FriendInfoVO Other = cellData as FriendInfoVO; m_SocialElement.SetFriendData(Other, m_SocialType); infoVOId = Other.UID; break; default: break; } }
/// <summary> /// 删除某一黑名单 /// </summary> /// <param name="uid">uid</param> /// <returns>黑名单</returns> public FriendInfoVO DelBlack(ulong uid) { for (int i = 0; i < m_BlackList.Count; i++) { if (m_BlackList[i].UID == uid) { FriendInfoVO result = m_BlackList[i]; m_BlackList.RemoveAt(i); return(result); } } return(null); }
/// <summary> /// 创建好友数据 /// </summary> /// <param name="data">协议结构</param> /// <returns>好友数据</returns> private FriendInfoVO CreateFriendInfo(FriendData data) { FriendInfoVO m_Info = new FriendInfoVO(); m_Info.UID = data.uid; m_Info.TID = (int)data.tid; m_Info.Name = data.name; m_Info.Level = (int)data.level; m_Info.Status = (FriendInfoVO.FriendState)data.status; m_Info.AddTime = data.add_time; Debug.Log(m_Info.Status + "<=======名字=====>" + m_Info.TID); return(m_Info); }
/// <summary> /// 黑名单列表 /// </summary> /// <param name="info">黑名单</param> public void AddBlack(FriendInfoVO info) { if (info.UID != 0) { for (int i = 0; i < m_BlackList.Count; i++) { if (m_BlackList[i].UID == info.UID) { m_BlackList.RemoveAt(i); } } m_BlackList.Add(info); } }
/// <summary> /// 获取共同玩过的列表 /// </summary> /// <param name="buf"></param> private void OnTogetherList(KProtoBuf buf) { S2C_SYNC_TOGETHERLIST msg = buf as S2C_SYNC_TOGETHERLIST; // Debug.Log("ssssssssssssss"); FriendProxy proxy = GameFacade.Instance.RetrieveProxy(ProxyName.FriendProxy) as FriendProxy; for (int i = 0; i < msg.togetherlist.Count; i++) { FriendInfoVO data = CreateFriendInfo(msg.togetherlist[i]); proxy.AddRecent(data); } GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_LIST_CHANGED); }
/// <summary> /// 加载好友数据 /// </summary> /// <param name="tip">tip物体</param> /// <param name="data">数据</param> private void LayoutFriendTip(GameObject tip, FriendInfoVO data) { if (data.UID > 0) { SetEmptyRootActive(false); Initialize(); m_PlayerName.text = data.Name; m_Level.text = string.Format(TableUtil.GetLanguageString("character_text_1019"), data.Level.ToString()); } else { //SetEmptyRootActive(true); } }
/// <summary> /// 添加好友 /// </summary> /// <param name="info">好友数据</param> public void AddFriend(FriendInfoVO info) { if (info.UID != 0 && info.UID != GetServerListProxy().GetCurrentCharacterVO().UId) { for (int i = 0; i < m_FriendList.Count; i++) { if (m_FriendList[i].UID == info.UID) { m_FriendList.RemoveAt(i); } } m_FriendList.Add(info); } //Debug.Log(m_FriendList.Count); }
/// <summary> /// 好友或黑名单数据变化 /// </summary> /// <param name="buf">协议内容</param> private void OnSyncFriend(KProtoBuf buf) { S2C_SYNC_FRIEND msg = buf as S2C_SYNC_FRIEND; FriendProxy proxy = GameFacade.Instance.RetrieveProxy(ProxyName.FriendProxy) as FriendProxy; FriendInfoVO data = CreateFriendInfo(msg.friend_syc); if (msg.friend_syc.flag == 0) { proxy.AddFriend(data); } else { proxy.AddBlack(data); } GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_LIST_CHANGED, data); //Debugger.LogError("OnSyncFriend 1 >" + data.UID + "." + data.Name); }
/// <summary> /// 添加最近玩过的 /// </summary> /// <param name="info">数据</param> public void AddRecent(FriendInfoVO info) { if (info.UID == 0) { return; } for (int i = 0; i < m_RecentList.Count; i++) { if (m_RecentList[i].UID == info.UID) { m_RecentList.RemoveAt(i); } } if (GetBlack(info.UID) == null) { m_RecentList.Add(info); } }
/// <summary> /// 获取好友列表 /// </summary> /// <param name="buf"></param> private void OnFriendList(KProtoBuf buf) { S2C_SYNC_FRIENDLIST msg = buf as S2C_SYNC_FRIENDLIST; FriendProxy proxy = GameFacade.Instance.RetrieveProxy(ProxyName.FriendProxy) as FriendProxy; for (int i = 0; i < msg.friendlist.Count; i++) { FriendInfoVO data = CreateFriendInfo(msg.friendlist[i]); if (msg.friendlist[i].flag == 0) { proxy.AddFriend(data); } else { proxy.AddBlack(data); } } GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_LIST_CHANGED); //Debugger.LogError("OnSyncFriend 1 >" + data.UID + "." + data.Name); }
/// <summary> /// 添加数据到附近玩家列表 /// </summary> public void AddNearbyListData() { List <BaseEntity> list = GetGameplayProxy().GetPlayEntitiesExcludeSelf(); m_NearbyList.Clear(); for (int i = 0; i < list.Count; i++) { FriendInfoVO friendInfoVO = new FriendInfoVO(); friendInfoVO.UID = list[i].GetPlayerId(); Debug.Log("附近的人UID-------->" + friendInfoVO.UID); if (friendInfoVO.UID == GetServerListProxy().GetCurrentCharacterVO().UId) { return; } friendInfoVO.Name = list[i].GetName(); friendInfoVO.Level = (int)list[i].GetLevel(); friendInfoVO.TID = (int)list[i].GetTemplateID(); //Debug.Log("附近的人TID-------->" + friendInfoVO.TID); if (GetBlack(friendInfoVO.UID) == null) { m_NearbyList.Add(friendInfoVO); } } }
/// <summary> /// 添加黑名单 /// </summary> /// <param name="buf">协议内容</param> private void OnAddBlackBack(KProtoBuf buf) { S2C_ADD_BLACK_BACK msg = buf as S2C_ADD_BLACK_BACK; FriendProxy proxy = GameFacade.Instance.RetrieveProxy(ProxyName.FriendProxy) as FriendProxy; if (msg.code == 1) { FriendInfoVO data = CreateFriendInfo(msg.friend_black); proxy.DelFriend(data.UID); proxy.DelBlack(data.UID); if (msg.friend_black.flag == 0) { proxy.AddFriend(data); } else { proxy.AddBlack(data); } GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_LIST_CHANGED, data); //Debugger.LogError("add black"); } //Debugger.LogError("OnAddBlackBack "); }