Esempio n. 1
0
        public static FriendUser CreateFromFriendInfo(FriendInfo friendInfo)
        {
            var friendUser = new FriendUser
            {
                PlayFabId         = friendInfo.FriendPlayFabId,
                Name              = friendInfo.Profile.DisplayName,
                Level             = friendInfo.Profile.Statistics?.FirstOrDefault(x => x.Name == "Level")?.Value ?? 1,
                LastLoginDateTime = friendInfo.Profile.LastLogin ?? DateTime.Now,
                CharacterId       = $"character-{string.Format("{0:D8}", friendInfo.Profile.Statistics?.FirstOrDefault(x => x.Name == "CharacterId")?.Value ?? 1)}",
                CharacterLevel    = friendInfo.Profile.Statistics?.FirstOrDefault(x => x.Name == "CharacterLevel")?.Value ?? 1
            };

            return(friendUser);
        }
Esempio n. 2
0
        /// <summary>
        /// 初期化する。
        /// </summary>
        /// <param name="friendUser"></param>
        public void Initialize(FriendUser friendUser)
        {
            FriendUser = friendUser;

            _userNameText.text          = friendUser.Name;
            _userLevelText.text         = $"Lv.{friendUser.Level}";
            _lastLoginDateTimeText.text = friendUser.LastLoginDateTime.ToString();

            var character = TitleDataManager.CharacterMaster[friendUser.CharacterId];

            _characterName.text    = character.Name;
            _characterLevel.text   = $"Lv.{friendUser.CharacterLevel}";
            _characterImage.sprite = _controller.CharacterSprites[friendUser.CharacterId];

            _button.OnClickAsObservable().ThrottleFirst(TimeSpan.FromMilliseconds(500)).Subscribe(_ => RemoveFriendAsync().Forget());
        }
        public static async UniTask SyncPlayFabToClientAsync()
        {
            var request = new GetFriendsListRequest
            {
                ProfileConstraints = new PlayerProfileViewConstraints
                {
                    ShowDisplayName = true,
                    ShowLastLogin   = true,
                    ShowStatistics  = true,
                }
            };

            var response = await PlayFabClientAPI.GetFriendsListAsync(request);

            if (response.Error != null)
            {
                throw new PlayFabErrorException(response.Error);
            }

            Friends = response.Result.Friends.Select(x => FriendUser.CreateFromFriendInfo(x)).ToDictionary(y => y.PlayFabId);
        }