public void SetItem(UserLeaderboardData data) { if (data != null) { if (_facebookManager == null) { _facebookManager = FacebookManager.Instance; } _positionText.text = (data.Position + 1).ToString(); _scoresText.text = data.LeaderboardValue.ToString(); _nameText.text = data.DisplayName; if (_facebookManager != null) { if (_facebookManager.CurrentUserFacebookUserInfo.id == data.FacebookId) { _nameText.text = "You"; _userIconFrame.sprite = _iconFramePlayer; var fbUser = _facebookManager.CurrentUserFacebookUserInfo; if (fbUser.ProfilePicture != null) { _userImage.sprite = fbUser.ProfilePicture; Debug.Log("Switching image player"); } else { fbUser.OnImageLoaded += () => { _userImage.sprite = fbUser.ProfilePicture; Debug.Log("Switching image player"); }; } } if (!string.IsNullOrEmpty(data.FacebookId) && _facebookManager.FriendUserFacebookInfos != null && _facebookManager.FriendUserFacebookInfos.Exists(f => f.id == data.FacebookId)) { var fbUser = _facebookManager.FriendUserFacebookInfos.First(f => f.id == data.FacebookId); if (fbUser.ProfilePicture != null) { _userImage.sprite = fbUser.ProfilePicture; Debug.Log("Switching image"); } else { fbUser.OnImageLoaded += () => { _userImage.sprite = fbUser.ProfilePicture; Debug.Log("Switching image"); }; } } } else { Debug.Log("facebook == null"); } } }
private void CreateItem(UserLeaderboardData itemData) { var itemGameObject = Instantiate(_leaderboardItemGameObject); itemGameObject.transform.SetParent(_rootTransform); itemGameObject.transform.localScale = Vector3.one; itemGameObject.SetActive(true); var itemObject = itemGameObject.GetComponent <ScoresLeaderboardItem>(); itemObject.SetItem(itemData); _items.Add(itemGameObject); }
public void SetItem(object data, UIListType itemtype) { _data = data as UserLeaderboardData; if (_facebookManager == null) { _facebookManager = FacebookManager.Instance; } if (_data != null) { _userPlace.text = (_data.Position + 1).ToString(); _userName.text = _data.DisplayName; _userScore.text = _data.LeaderboardValue.ToString(); if (_facebookManager != null) { if (_facebookManager.CurrentUserFacebookUserInfo.id == _data.FacebookId) { _userName.text = "You"; _userIconFrame.sprite = _iconFramePlayer; var fbUser = _facebookManager.CurrentUserFacebookUserInfo; if (fbUser.ProfilePicture != null) { _userIcon.sprite = fbUser.ProfilePicture; } else { fbUser.OnImageLoaded += () => { _userIcon.sprite = fbUser.ProfilePicture; }; } } if (!string.IsNullOrEmpty(_data.FacebookId) && _facebookManager.FriendUserFacebookInfos != null && _facebookManager.FriendUserFacebookInfos.Exists(f => f.id == _data.FacebookId)) { var fbUser = _facebookManager.FriendUserFacebookInfos.First(f => f.id == _data.FacebookId); if (fbUser.ProfilePicture != null) { _userIcon.sprite = fbUser.ProfilePicture; } else { fbUser.OnImageLoaded += () => { _userIcon.sprite = fbUser.ProfilePicture; }; } } } } }
public PlayFabManager GetPlayersLevelLeaderboard() { if (PlayFabClientAPI.IsClientLoggedIn()) { List <PlayerLeaderboardEntry> respone = null; PlayerProfileViewConstraints profileViewConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true, ShowLinkedAccounts = true }; GetFriendLeaderboardRequest request = new GetFriendLeaderboardRequest() { StatisticName = _levelsCountLeaderboardId, MaxResultsCount = 100, IncludeFacebookFriends = true, ProfileConstraints = profileViewConstraints }; PlayFabClientAPI.GetFriendLeaderboard(request, (result) => { respone = result.Leaderboard; var newLeaderboardList = new List <UserLeaderboardData>(); foreach (var playerLeaderboardEntry in respone) { string fbId = ""; var linkedAccounts = playerLeaderboardEntry.Profile.LinkedAccounts; if (linkedAccounts != null && linkedAccounts.Any()) { foreach (var linkedPlatformAccountModel in linkedAccounts) { if (linkedPlatformAccountModel.Platform.Equals(LoginIdentityProvider.Facebook)) { fbId = linkedPlatformAccountModel.PlatformUserId; } } } var userData = new UserLeaderboardData() { DisplayName = playerLeaderboardEntry.DisplayName, PlayFabId = playerLeaderboardEntry.PlayFabId, Position = playerLeaderboardEntry.Position, LeaderboardValue = playerLeaderboardEntry.StatValue, FacebookId = fbId }; newLeaderboardList.Add(userData); } if (OnLevelsLeaderboardLoaded != null) { OnLevelsLeaderboardLoaded.Invoke(newLeaderboardList); } }, (error) => { Debug.Log("Error getting game leaderboard:"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); } return(this); }