/// <summary>
    /// Método que nos permite inicializar los datos del jugador que inicio sesión.
    /// </summary>
    /// <param name="_PlayFabId">ID único que oermite identificar al jugador.</param>
    private void GetPlayFabPlayerData(string _PlayFabId)
    {
        // Guardamos el ID.
        DatosJugador.Get.PlayFabID = _PlayFabId;

        // Guardamos el nombre del usuario.
        var requesProfile = new GetPlayerProfileRequest()
        {
            PlayFabId = _PlayFabId
        };

        PlayFabClientAPI.GetPlayerProfile(requesProfile,
                                          result =>
        {
            // Se guarda el nombre del jugador y se cargan los datos.
            DatosJugador.Get.Nombre = result.PlayerProfile.DisplayName;
            DatosJugador.Get.ObtenerDatos();

            // Invocamos el evento de que fue autentificado.
            evntAutentificado?.Invoke();

            // Cargamos la escena del menu.
            SceneManager.LoadScene("Lobby", LoadSceneMode.Single);
        },
                                          error =>
        {
            Debug.LogError(error.GenerateErrorReport());
        });
    }
    internal void UpdatePlayerProfile(string _playfabID)
    {
        var updateRequest = new GetPlayerProfileRequest();

        updateRequest.PlayFabId = _playfabID;
        PlayFabClientAPI.GetPlayerProfile(updateRequest, OnPlayerProfileSuccess, OnPlayerProfileFailure);
    }
    private void OnMatchGet(GetMatchResult res)
    {
        serverIp   = res.ServerDetails.IPV4Address;
        serverPort = res.ServerDetails.Ports[0].Num;
        Debug.Log($"Server Details - IP:{serverIp} | Port:{serverPort}");

        int enemyIdx    = res.Members.FindIndex(x => x.Entity.Id != loginManager.playerData.accountInfo.entityId);
        var enemyEntity = res.Members[enemyIdx].Entity;

        // Getting enemy name from entityid -> playfabid -> profilename
        var entityRequest = new GetEntityProfileRequest
        {
            Entity = new PlayFab.ProfilesModels.EntityKey
            {
                Id   = enemyEntity.Id,
                Type = enemyEntity.Type
            }
        };

        PlayFabProfilesAPI.GetProfile(entityRequest, entityRes =>
        {
            var enemyPlayfabId = entityRes.Profile.Lineage.MasterPlayerAccountId;
            var profileRequest = new GetPlayerProfileRequest
            {
                PlayFabId = enemyPlayfabId
            };
            PlayFabClientAPI.GetPlayerProfile(profileRequest, profileRes =>
            {
                enemyName = profileRes.PlayerProfile.DisplayName;
                StartMatch();
            }, OnError);
        }, OnError);
    }
    public void CreateEntry(string user, Action <LoginResult> onLogin, Action <PlayFabError> onFailure)
    {
        var request = new LoginWithCustomIDRequest();

        request.TitleId       = "8141";
        request.CreateAccount = true;
        request.CustomId      = user;

        PlayFabClientAPI.LoginWithCustomID(request, result => OnSignInSuccess(user, result,
                                                                              loginResult =>
        {
            var infoRequest                = new GetPlayerProfileRequest();
            infoRequest.PlayFabId          = loginResult.PlayFabId;
            infoRequest.ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowDisplayName = true,
                ShowLocations   = true
            };

            PlayFabClientAPI.GetPlayerProfile(infoRequest,
                                              infoResult =>
            {
                uniqueID = infoResult.PlayerProfile.PlayerId;

                var location      = infoResult.PlayerProfile.Locations.Last();
                characterLocation = useCityAsLocation ? location.City.ToString() : location.CountryCode.ToString();
                onLogin(loginResult);
                OnLogin();
            }, error => onFailure(error));
        }),
                                           onFailure);
    }
        private void OnAuthSuccess()
        {
            CurrentAuth.type = AuthType.Login;

            if (_isRememberMe)
            {
                _isRememberMe = false;

                string customId = Guid.NewGuid().ToString();
                _rememberMeInfo = new RememberMeInfo(true, customId);
                LinkCustomIDRequest linkRequest = new LinkCustomIDRequest()
                {
                    CustomId  = customId,
                    ForceLink = true,
                };
                PlayFabClientAPI.LinkCustomID(linkRequest, OnLinkSuccess, OnAuthFailure);
            }
            GetPlayerProfileRequest profileRequest = new GetPlayerProfileRequest()
            {
                ProfileConstraints = new PlayerProfileViewConstraints()
                {
                    ShowDisplayName = true,
                }
            };

            PlayFabClientAPI.GetPlayerProfile(profileRequest, OnGetProfileSuccess, OnAuthFailure);
        }
Exemple #6
0
        public void MultiplePlayerApiCall(UUnitTestContext testContext)
        {
            if (authenticationContext1?.ClientSessionTicket == null || authenticationContext2?.ClientSessionTicket == null)
            {
                testContext.Skip("To run this test MultipleLoginWithStaticMethods test should be passed and store authenticationContext values");
            }

            var getPlayerProfileRequest = new GetPlayerProfileRequest()
            {
                AuthenticationContext = authenticationContext1,
                PlayFabId             = authenticationContext1.PlayFabId
            };
            var getPlayerProfileRequest2 = new GetPlayerProfileRequest()
            {
                AuthenticationContext = authenticationContext2,
                PlayFabId             = authenticationContext2.PlayFabId
            };

            var getPlayerProfileTask  = clientApi.GetPlayerProfileAsync(getPlayerProfileRequest, null, testTitleData.extraHeaders).Result;
            var getPlayerProfileTask2 = clientApi.GetPlayerProfileAsync(getPlayerProfileRequest2, null, testTitleData.extraHeaders).Result;

            testContext.NotNull(getPlayerProfileTask.Result, "GetPlayerProfile Failed for getPlayerProfileRequest");
            testContext.NotNull(getPlayerProfileTask2.Result, "GetPlayerProfile Failed for getPlayerProfileRequest2");
            testContext.IsNull(getPlayerProfileTask.Error, "GetPlayerProfile error occured for getPlayerProfileRequest: " + getPlayerProfileTask.Error?.ErrorMessage ?? string.Empty);
            testContext.IsNull(getPlayerProfileTask2.Error, "GetPlayerProfile error occured for getPlayerProfileRequest2: " + getPlayerProfileTask2.Error?.ErrorMessage ?? string.Empty);

            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
    public void getPlayerProfile(string playFabId, Action <GetPlayerProfileResult> onSucess, Action <PlayFabError> onFailure)
    {
        var request = new GetPlayerProfileRequest {
            PlayFabId = playFabId
        };

        PlayFabClientAPI.GetPlayerProfile(request, onSucess, onFailure);
    }
    //public void OnClickHubLeaderboard()
    //{
    //    hubPanel.SetActive(false);
    //    leaderboardPanel.SetActive(true);
    //}

    //public void OnClickHubGuild()
    //{
    //    hubPanel.SetActive(false);
    //    rosterPanel.SetActive(true);
    //}

    public void LoadPlayerProfile()
    {
        var request = new GetPlayerProfileRequest {
            PlayFabId = userId
        };

        PlayFabClientAPI.GetPlayerProfile(request, OnLoadPlayerProfileSuccess, OnUpdateFailure);
    }
    void GetPlayerData(string playfabID)
    {
        var infoRequest = new GetPlayerProfileRequest {
            PlayFabId = playfabID, ProfileConstraints = new PlayerProfileViewConstraints {
                ShowContactEmailAddresses = true
            }
        };

        PlayFabClientAPI.GetPlayerProfile(infoRequest, Profileresult =>
        {
            if (Profileresult.PlayerProfile.ContactEmailAddresses != null)
            {
                if (Profileresult.PlayerProfile.ContactEmailAddresses.Count != 0)
                {
                    if (Profileresult.PlayerProfile.ContactEmailAddresses[0].VerificationStatus == EmailVerificationStatus.Confirmed)
                    {
                        GameData.data.PlayfabLogin = true;
                        if (!mobileLogin)
                        {
                            LinkMobileID();
                        }
                        else
                        {
                            UnLinkMobileID();
                        }
                    }
                    else
                    {
                        //testRemove();
                        CloseSignInScreen();
                        UserEmail = Profileresult.PlayerProfile.ContactEmailAddresses[0].EmailAddress;
                        Debug.Log("User email not confirmed");
                        ShowEmailSentScreen();
                        //ShowConfirmScreen(true);
                    }
                }
                else
                {
                    NoContactEmail(playfabID);
                }
            }
            else
            {
                NoContactEmail(playfabID);
            }
        }
                                          , failure =>
        {
            PlayFabClientAPI.ForgetAllCredentials();
            ShowSignInScreen();
            Debug.Log(failure.GenerateErrorReport());
            Debug.Log("Failed to get player data");
        });
    }
Exemple #10
0
    private void GetPlayerData()
    {
        var request = new GetPlayerProfileRequest();

        request.PlayFabId = playFabID;

        var constraints = new PlayerProfileViewConstraints();

        constraints.ShowContactEmailAddresses = true;

        request.ProfileConstraints = constraints;

        PlayFabClientAPI.GetPlayerProfile(request, OnPlayerDataResult, OnPlayFabError);
    }
    //-------------------------------------------------------------------------


    #region 로그인 시 가져와야 할 정보

    // 로그인 시 가져와야 할 정보
    // 1. 유저 이름
    // 2. 닉네임
    // 3. 가입한 email
    // 4. 저장한 데이터 (혼자하기 모드 클리어 정보, 업적, 권한 정보)

    void GetPlayerProfile(string playFabId)
    {
        var request = new GetPlayerProfileRequest {
            PlayFabId = playFabId, ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowDisplayName = true
            }
        };

        PlayFabClientAPI.GetPlayerProfile(request, OnGetPlayerProfileSuccess, OnGetPlayerProfileFailure);

        //PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest(){ PlayFabId = playFabId, ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true } }
        //                                                               , result => Debug.Log("The player's DisplayName profile data is: " + result.PlayerProfile.DisplayName)
        //                                                               , error => Debug.LogError( error.GenerateErrorReport() ) );
    }
Exemple #12
0
    public void Start()
    {
        //Gets the player name
        GetPlayerProfileRequest requestProfile = new GetPlayerProfileRequest();

        PlayFabClientAPI.GetPlayerProfile(requestProfile, result =>
        {
            UsernameText.text = result.PlayerProfile.DisplayName;
        }, error =>
        {
            Debug.Log(error.ErrorMessage);
        });

        UpdateCurrentGold();
        CheckUserInventory();
        GetFriends();
    }
    public void OnLoggedIn()
    {
        GetPlayerProfileRequest getProfileRequest = new GetPlayerProfileRequest
        {
            PlayFabId          = LoginRegister.instance.playFabId,
            ProfileConstraints = new PlayerProfileViewConstraints
            {
                ShowDisplayName = true
            }
        };

        PlayFabClientAPI.GetPlayerProfile(getProfileRequest,
                                          result =>
        {
            profile = result.PlayerProfile;
            Debug.Log("Loaded in player: " + profile.DisplayName);
        },
                                          error => Debug.Log(error.ErrorMessage)
                                          );
    }
        public static async Task <PlayerProfileModel> GetPlayerProfileInfo(string titlePlayerId)
        {
            var requestData = new GetPlayerProfileRequest()
            {
                PlayFabId = titlePlayerId,
            };

            requestData.ProfileConstraints = new PlayerProfileViewConstraints();
            requestData.ProfileConstraints.ShowLocations   = true;
            requestData.ProfileConstraints.ShowDisplayName = true;

            var result = await PlayFabServerAPI.GetPlayerProfileAsync(requestData);

            if (result.Error == null)
            {
                return(result.Result.PlayerProfile);
            }
            else
            {
                return(null);
            }
        }
Exemple #15
0
    public void Login()
    {
        PlayFab.PlayFabSettings.TitleId = TitleID;

        string email    = _LoginEmailField.text;
        string password = _LoginPasswordField.text;

        PlayFab.ClientModels.LoginWithEmailAddressRequest loginRequest = new LoginWithEmailAddressRequest();
        loginRequest.Email    = email;
        loginRequest.Password = password;
        loginRequest.TitleId  = TitleID;

        PlayFab.PlayFabClientAPI.LoginWithEmailAddress(
            loginRequest,
            (LoginResult result) => {
            PlayfabHelper.LastLoginInfo = result.LastLoginTime;
            PlayfabHelper.NewUser       = result.NewlyCreated;
            PlayfabHelper.PlayerID      = result.PlayFabId;

            PlayFab.ClientModels.GetPlayerProfileRequest getProfileRequest = new GetPlayerProfileRequest();
            getProfileRequest.PlayFabId = result.PlayFabId;
            PlayFab.PlayFabClientAPI.GetPlayerProfile(
                getProfileRequest,
                (GetPlayerProfileResult result2) => {
                PlayfabHelper.UserName = result2.PlayerProfile.DisplayName;


                UnityEngine.SceneManagement.SceneManager.LoadScene(1);
            },
                (PlayFab.PlayFabError error) => {
                Debug.LogError(error.GenerateErrorReport());
            }
                );
        },
            (PlayFab.PlayFabError error) => {
            Debug.LogError(error.GenerateErrorReport());
        }
            );
    }
Exemple #16
0
    public void LoggedIn()
    {
        GetPlayerProfileRequest getProfReq = new GetPlayerProfileRequest
        {
            PlayFabId          = UIManager.loginInstance.playFabId,
            ProfileConstraints = new PlayerProfileViewConstraints
            {
                ShowDisplayName = true
            }
        };


        PlayFabClientAPI.GetPlayerProfile(getProfReq,
                                          result =>
        {
            profile = result.PlayerProfile;
            Debug.Log("Logged in as :" + profile.DisplayName);
        },
                                          error =>
        {
            Debug.Log(error.ErrorMessage);
        }
                                          );
    }
Exemple #17
0
    public void Initialize()
    {
        PlayerPrefs.DeleteAll();
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            /*
             * Please change the titleId below to your own titleId from PlayFab Game Manager.
             * If you have already set the value in the Editor Extensions, this can be skipped.
             */
            PlayFabSettings.staticSettings.TitleId = "231EE";
        }
        if (PlayerPrefs.HasKey("PASSWORD"))
        {
            if (PlayerPrefs.HasKey("USERNAME"))
            {
                UserName        = PlayerPrefs.GetString("USERNAME");
                UserNameOrEmail = PlayerPrefs.GetString("USERNAME");
                UserPassword    = PlayerPrefs.GetString("PASSWORD");
                var usernameRequest = new LoginWithPlayFabRequest {
                    Username = UserName, Password = UserPassword
                };
                PlayFabClientAPI.LoginWithPlayFab(usernameRequest, result =>
                {
                    Debug.Log("Username login was a success");
                    GetPlayerData(result.PlayFabId);
                }, error =>
                {
                    InitialMobileLogin();
                    Debug.Log("email login error");
                });
            }
            else if (PlayerPrefs.HasKey("EMAIL"))
            {
                UserEmail       = PlayerPrefs.GetString("EMAIL");
                UserNameOrEmail = PlayerPrefs.GetString("EMAIL");
                UserPassword    = PlayerPrefs.GetString("PASSWORD");
                var mailRequest = new LoginWithEmailAddressRequest {
                    Email = UserEmail, Password = UserPassword
                };
                PlayFabClientAPI.LoginWithEmailAddress(mailRequest, result =>
                {
                    Debug.Log("Email login was a success");
                    GetPlayerData(result.PlayFabId);
                }, error =>
                {
                    InitialMobileLogin();
                    Debug.Log("email login error");
                });
            }
            else
            {
                InitialMobileLogin();
            }
        }
        else
        {
            InitialMobileLogin();
        }

        void InitialMobileLogin()
        {
            Debug.Log("Dont have saved Credentials");
            if (Application.platform == RuntimePlatform.Android)
            {
                var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                    AndroidDeviceId = GetMobileID(), CreateAccount = false
                };
                PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, result =>
                {
                    Debug.Log("Mobile login was a success");
                    GameData.data.PlayfabLogin = true;
                    mobileLogin = true;
                    CheckUserInfo(result.PlayFabId);
                }, PlayFabError =>
                {
                    ShowQuestionSceen();
                    Debug.Log("Mobile login error");
                });
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                var requestIOS = new LoginWithIOSDeviceIDRequest {
                    DeviceId = GetMobileID(), CreateAccount = false
                };
                PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, result =>
                {
                    Debug.Log("Mobile login was a success");
                    GameData.data.PlayfabLogin = true;
                    mobileLogin = true;
                    CheckUserInfo(result.PlayFabId);
                }, PlayFabError =>
                {
                    ShowQuestionSceen();
                    Debug.Log("Mobile login error");
                });
            }
            else
            {
                var requestEditor = new LoginWithIOSDeviceIDRequest {
                    DeviceId = GetMobileID(), CreateAccount = false
                };
                PlayFabClientAPI.LoginWithIOSDeviceID(requestEditor, result =>
                {
                    Debug.Log("Mobile login was a success");
                    GameData.data.PlayfabLogin = true;
                    mobileLogin = true;
                    CheckUserInfo(result.PlayFabId);
                }, PlayFabError =>
                {
                    ShowQuestionSceen();
                    Debug.Log("Mobile login error");
                });
            }
        }

        void CheckUserInfo(string playfabID)
        {
            var info = new GetAccountInfoRequest {
                PlayFabId = playfabID
            };

            PlayFabClientAPI.GetAccountInfo(info, result =>
            {
                if (result.AccountInfo.Username != null)
                {
                    var infoRequest = new GetPlayerProfileRequest {
                        PlayFabId = playfabID, ProfileConstraints = new PlayerProfileViewConstraints {
                            ShowContactEmailAddresses = true
                        }
                    };
                    PlayFabClientAPI.GetPlayerProfile(infoRequest, Profileresult =>
                    {
                        if (Profileresult.PlayerProfile.ContactEmailAddresses != null)
                        {
                            if (Profileresult.PlayerProfile.ContactEmailAddresses.Count != 0)
                            {
                                if (Profileresult.PlayerProfile.ContactEmailAddresses[0].VerificationStatus == EmailVerificationStatus.Confirmed)
                                {
                                    GameData.data.PlayfabLogin = true;
                                    ShowContinueAs(result.AccountInfo.Username);
                                }
                                else
                                {
                                    UserEmail = Profileresult.PlayerProfile.ContactEmailAddresses[0].EmailAddress;
                                    Debug.Log("User email not confirmed");
                                    ShowEmailSentScreen();
                                    //ShowConfirmScreen(true); TODO
                                }
                            }
                            else
                            {
                                NoContactEmail(result.AccountInfo.PlayFabId);
                            }
                        }
                        else
                        {
                            NoContactEmail(result.AccountInfo.PlayFabId);
                        }
                    }
                                                      , Infofailure =>
                    {
                        ShowSignInScreen();
                        Debug.Log(Infofailure.GenerateErrorReport());
                        Debug.Log("Failed to get player data");
                    });
                }
                else
                {
                    ShowQuestionSceen();
                }
            }, failure => { Debug.Log("Failed to get user account info"); });
        }
    }