Exemplo n.º 1
0
    /// <summary>
    /// 从服务器获取玩家搜索数据
    /// </summary>
    private void GetSearchList(Transform inputTF)
    {
        StaticData.DebugGreen("请求玩家搜索数据~~~");
        //获取输入框内容
        string inputText = inputTF.GetComponent <Text>().text;

        if (inputText.Length == 0)
        {
            //提示弹窗
            string tipStr = LocalizationDefineHelper.GetStringNameById(120125);
            StaticData.CreateToastTips(tipStr);
            return;
        }
        //if (inputText == StaticData.Uid.ToString())
        //{
        //    string searchSelfTip = LocalizationDefineHelper.GetStringNameById(120132);
        //    StaticData.CreateToastTips(searchSelfTip);
        //    return;
        //}
        _buttonRefresh.gameObject.SetActive(false);
        _buttonRefreshGrey.gameObject.SetActive(false);
        scSearchInfo = new SCSearch();
        CSSearch csSearch = new CSSearch()
        {
            SearchContext = inputText
        };

        ProtocalManager.Instance().SendCSSearch(csSearch, (scSearch) =>
        {
            if (scSearch == null)
            {
                StaticData.DebugGreen("搜索玩家结果为空~~~");
                ShowEmptyTip(FriendTabTags.TabRecommend);
                GenerateSearchListUI(0);
                return;
            }
            scSearchInfo  = scSearch;
            int playerNum = scSearchInfo.Search.Count;
            GenerateSearchListUI(playerNum);
        }, (error) => { });
    }
Exemplo n.º 2
0
    /// <summary>
    /// 生成好友列表中LoopItem后的回调函数
    /// 改变每个LoopItem的参数
    /// </summary>
    /// <param name="idx"></param>
    public async void ScrollCellIndex(int idx)
    {
        SetFriendship(Friendship.Normal);
        if (uiFriendComponent.isRecommendUI)
        {
            listRecommendInfo = StaticData.playerInfoData.listRecommendInfo;

            scOtherStruct = listRecommendInfo[idx];
            if (string.IsNullOrEmpty(scOtherStruct.ImageAddress))
            {
                _iconImage.sprite = ChatTool.GetIcon(scOtherStruct.FriendImage);
            }
            else
            {
                _iconImage.sprite = await ChatTool.GetIcon(scOtherStruct.ImageAddress);
            }

            //根据经验计算等级
            int level = StaticData.GetPlayerLevelByExp(scOtherStruct.FriendExperience);
            _levelNum.GetComponent <Text>().text = level.ToString();
            //昵称
            _nickname.GetComponent <Text>().text = scOtherStruct.FriendName;
            //_nickname.GetComponent<Text>().text = scOtherStruct.Uid.ToString();
        }
        else
        {
            scSearch = uiFriendComponent.scSearchInfo;
            if (scSearch != null)
            {
                //根据经验计算等级
                int level = StaticData.GetPlayerLevelByExp(scSearch.Search[idx].FriendExperience);
                _levelNum.GetComponent <Text>().text = level.ToString();

                //昵称
                _nickname.GetComponent <Text>().text = scSearch.Search[idx].FriendName;
                if (string.IsNullOrEmpty(scSearch.Search[idx].ImageAddress))
                {
                    _iconImage.sprite = ChatTool.GetIcon(scSearch.Search[idx].FriendImage);
                }
                else
                {
                    _iconImage.sprite = await ChatTool.GetIcon(scSearch.Search[idx].ImageAddress);
                }

                //_nickname.GetComponent<Text>().text = scSearch.Search[idx].Uid.ToString();
                if (scSearch.Search[idx].IsApply)
                {
                    SetFriendship(Friendship.IsApply);
                }
                else
                {
                    scOtherStruct = new SCFriendInfo()
                    {
                        Uid              = scSearch.Search[idx].Uid,
                        FriendName       = scSearch.Search[idx].FriendName,
                        FriendExperience = scSearch.Search[idx].FriendExperience,
                        FriendImage      = scSearch.Search[idx].FriendImage,
                        Online           = scSearch.Search[idx].Online
                    };
                }
                //判定是否在好友列表中
                RepeatedField <SCFriendInfo> listFriendInfo = StaticData.playerInfoData.listFriendInfo;
                foreach (SCFriendInfo friendInfo in listFriendInfo)
                {
                    if (friendInfo.Uid == scSearch.Search[idx].Uid)
                    {
                        SetFriendship(Friendship.IsFriend);
                    }
                }
            }
            else
            {
                //需添加空背景,todo
                StaticData.DebugGreen("搜索玩家结果为空~~~");
            }
        }
        if ((scOtherStruct != null && scOtherStruct.Online) || (scSearch != null && scSearch.Search[idx].Online))
        {
            _online.gameObject.SetActive(true);
            _onlineBg.gameObject.SetActive(true);
            _outline.gameObject.SetActive(false);
            _outlineBg.gameObject.SetActive(false);
        }
        else
        {
            _outline.gameObject.SetActive(true);
            _outlineBg.gameObject.SetActive(true);
            _online.gameObject.SetActive(false);
            _onlineBg.gameObject.SetActive(false);
        }
    }