예제 #1
0
 /// <summary>
 ///
 /// </summary>
 void Awake()
 {
     FriendManager     = FindObjectOfType <bl_FriendList>();
     onlineFirst       = SortOnline;
     LogText.text      = string.Empty;
     ArrowImage.sprite = (onlineFirst == true) ? UpArrowSprite : BottomArrowSprite;
     UpdateFriendList(true);
     if (LogText != null)
     {
         LogText.canvasRenderer.SetAlpha(0);
     }
     if (!PhotonNetwork.IsConnected)
     {
         Panel.SetActive(false);
     }
 }
예제 #2
0
    /// <summary>
    ///
    /// </summary>
    public void Remove()
    {
        bl_FriendList manager = FindObjectOfType <bl_FriendList>();

        manager.RemoveFriend(NameText.text);
    }
예제 #3
0
    /// <summary>
    ///
    /// </summary>
    public void UpdateFriendList(bool instance = false)
    {
        if (FriendManager == null)
        {
            FriendManager = FindObjectOfType <bl_FriendList>();
        }
        if (FriendManager.FriendList.Count <= 0 || PhotonNetwork.InRoom)
        {
            return;
        }

        FriendInfo[] friends = FriendManager.FriendList.ToArray();

        if (instance)
        {
            CleanCacheList();
            if (friends.Length > 0)
            {
                List <FriendInfo> OnlineFriends  = new List <FriendInfo>();
                List <FriendInfo> OfflineFriends = new List <FriendInfo>();

                for (int i = 0; i < friends.Length; i++)
                {
                    if (friends[i].UserId != "Null")
                    {
                        if (onlineFirst)
                        {
                            if (friends[i].IsOnline)
                            {
                                OnlineFriends.Add(friends[i]);
                            }
                            else
                            {
                                OfflineFriends.Add(friends[i]);
                            }
                        }
                        else
                        {
                            GameObject    f    = Instantiate(FriendUIPrefab) as GameObject;
                            bl_FriendInfo info = f.GetComponent <bl_FriendInfo>();
                            info.GetInfo(friends[i]);
                            f.name = friends[i].UserId;
                            cacheFriendsInfo.Add(info);

                            f.transform.SetParent(PanelList, false);
                        }
                    }
                }

                if (onlineFirst)
                {
                    if (OnlineFriends.Count > 0)
                    {
                        InstanceFriend(OnlineFriends.ToArray());
                    }
                    if (OfflineFriends.Count > 0)
                    {
                        InstanceFriend(OfflineFriends.ToArray());
                    }
                }
                ConnectFriendsText.text = OnlineFriends.Count.ToString();
            }
        }
        else//Just update list
        {
            for (int i = 0; i < cacheFriendsInfo.Count; i++)
            {
                if (cacheFriendsInfo[i] != null)
                {
                    cacheFriendsInfo[i].RefreshInfo(friends);
                }
                else
                {
                    cacheFriendsInfo.RemoveAt(i);
                }
            }
        }
        UpdateCount(friends);
    }