Esempio n. 1
0
    private async Task <string> AssignBucket(EntityTokenResponse entityToken, string player)
    {
        SetStatus($"Assigning bucket for {player}...");
        await SetBucket(entityToken, player);

        await Task.Delay(750);

        string bucket = await UpdateBucketMetadata(entityToken);

        return(bucket);
    }
Esempio n. 2
0
    private void OnLoginSuccessPlayfab(LoginResult result)
    {
        Debug.Log("Sucessfull Login to Playfab");
        playfabToken = result.EntityToken;
        var request = new GetAccountInfoRequest {
            PlayFabId = result.PlayFabId
        };

        PlayFabClientAPI.GetAccountInfo(request, OnAccountInfoSucess, OnAPIFailure);
        Debug.Log("f");
    }
Esempio n. 3
0
        private void OnPlayerLogin(LoginResult loginResult)
        {
            this.entityKey         = null;
            this.lastTokenResponse = loginResult.EntityToken;
            if (!IsImpersonating)
            {
                PlayerName      = "Player" + "#" + loginResult.EntityToken.Entity.Id.Substring(0, 4);
                this.PlayerName = GameServiceManager.GameService.PlayerName;
            }

            if (GameServiceManager.GameService.IsSignedIn)
            {
#if UNITY_IOS
                PlayFabClientAPI.LinkIOSDeviceID(new LinkIOSDeviceIDRequest()
                {
                    DeviceId = SystemInfo.deviceUniqueIdentifier, ForceLink = false
                }, (LinkIOSDeviceIDResult r) => { }, (PlayFabError e) => { });
#endif

#if UNITY_ANDROID
                PlayFabClientAPI.LinkAndroidDeviceID(new LinkAndroidDeviceIDRequest()
                {
                    AndroidDeviceId = SystemInfo.deviceUniqueIdentifier, ForceLink = false
                }, (LinkAndroidDeviceIDResult r) => { }, (PlayFabError e) => { });
#endif
            }


            if (PlayerName == string.Empty)
            {
            }

            this.GroupManager = new PlayFabGroupManager();

            if (!IsImpersonating && PlayerName != string.Empty)
            {
                PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest()
                {
                    DisplayName = this.PlayerName
                }, new Action <UpdateUserTitleDisplayNameResult>(OnUpdaterUserDisplayName), new Action <PlayFabError>(OnUpdaterUserDisplayNameError));
            }
        }
Esempio n. 4
0
    private Task <string> UpdateBucketMetadata(EntityTokenResponse entityToken)
    {
        var t = new TaskCompletionSource <string>();

        PlayFabLeaderboardsAPI.GetLeaderboardAroundEntity(new GetLeaderboardAroundEntityRequest()
        {
            Entity = new PlayFab.LeaderboardsModels.EntityKey()
            {
                Type = entityToken.Entity.Type,
                Id   = entityToken.Entity.Id
            },
            StatisticName = "Bucket",
            Offset        = 0
        },
                                                          (result) =>
        {
            int entityRank = result.Rankings[0].Rank;
            int bucket     = (entityRank - 1) / 5;
            PlayFabLeaderboardsAPI.UpdateStatistics(new UpdateStatisticsRequest()
            {
                EntityLeaderboardMetadata = currentPlayer,
                Statistics = new List <PlayFab.LeaderboardsModels.StatisticUpdate>()
                {
                    new PlayFab.LeaderboardsModels.StatisticUpdate()
                    {
                        Name     = "Bucket",
                        Value    = 1,
                        Metadata = bucket.ToString()
                    }
                }
            },
                                                    (response) => t.SetResult(bucket.ToString()),
                                                    PlayFabErrorHandler);
        },
                                                          PlayFabErrorHandler
                                                          );

        return(t.Task);
    }
Esempio n. 5
0
    private Task <bool> SetBucket(EntityTokenResponse entityToken, string metadata)
    {
        var t = new TaskCompletionSource <bool>();


        PlayFabLeaderboardsAPI.UpdateStatistics(new UpdateStatisticsRequest()
        {
            EntityLeaderboardMetadata = metadata,
            Statistics = new List <PlayFab.LeaderboardsModels.StatisticUpdate>()
            {
                new PlayFab.LeaderboardsModels.StatisticUpdate()
                {
                    Name  = "Bucket",
                    Value = 1
                }
            }
        },
                                                (response) => t.SetResult(true),
                                                PlayFabErrorHandler);

        return(t.Task);
    }
Esempio n. 6
0
    private async void OnPlayerLoggedIn(LoginResult success)
    {
        /* PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
         * {
         *  Entity = new PlayFab.CloudScriptModels.EntityKey()
         *  {
         *      Type = success.EntityToken.Entity.Type,
         *      Id = success.EntityToken.Entity.Id
         *  },
         *  FunctionName = "AssignBucket",
         *  FunctionParameter = playerText.text,
         *  GeneratePlayStreamEvent = true
         * },
         * (result) =>
         * {
         *  bucketText.text = result.FunctionResult.ToString();
         *  RefreshPlayerList();
         *  SetupBoard();
         *  ReloadLeaderboardData();
         * }
         * , PlayFabErrorHandler
         * ); */

        currentEntityToken = success.EntityToken;
        gameRunning        = false;
        if (success.NewlyCreated)
        {
            await SetDisplayName(currentPlayer);

            currentBucket = await AssignBucket(currentEntityToken, currentPlayer);

            AddPlayerToList(currentPlayer, currentBucket, currentEntityToken.Entity.Id);
        }
        HighlightCurrentPlayer();
        SetupBoard();
        ReloadLeaderboardData();
    }