コード例 #1
0
ファイル: RegisterManager.cs プロジェクト: perkoules/BinGo
 private void OnRegisterGuestSuccess(AddUsernamePasswordResult result)
 {
     playerDataSaver.SetUsername(username);
     playerDataSaver.SetEmail(email);
     playerDataSaver.SetPassword(password);
     PlayFabClientAPI.UpdateUserTitleDisplayName(
         new UpdateUserTitleDisplayNameRequest
     {
         DisplayName = username
     },
         resultSuccess =>
     {
         Debug.Log(username + " is the Display Name");
     },
         error =>
     {
         Debug.LogError(error.GenerateErrorReport());
         if (currentBuildLevel == 0)
         {
             success.OpenWindow();
             StartCoroutine(LoggingProcessSucceeded());
         }
     });
     playerDataSaver.SetCountry(countryDropdown.selectedText.text);
     playerDataSaver.SetAvatar(avatarDropdown.selectedText.text);
     SetPlayerData();
     playerDataSaver.SetIsGuest(0);
     success.OpenWindow();
 }
コード例 #2
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Login successful!");
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userPassword);
     addLoginPanel.SetActive(false);
 }
コード例 #3
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Congratulations, you made your first successful API call!");
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userpassword);
     addloginPanel.SetActive(false);
 }
コード例 #4
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Congratulations, you made your first successful API call!");
     RecordLoginData();
     loginPanel.SetActive(false);
     GetStats();
 }
コード例 #5
0
 /// <summary>
 /// Callback for AddUserNameAndPassword Success
 /// </summary>
 /// <param name="Result">  Result - from the API Call</param>
 static void OnAddUserNameAndPasswordSuccess(AddUsernamePasswordResult result)
 {
     if (OnPlayfabCallbackSuccess != null)
     {
         OnPlayfabCallbackSuccess("", PlayFabAPIMethods.AddUsernamePassword);
     }
 }
コード例 #6
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Congratulations, you made your first successful API call!");
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userPassword);
     loginSuccess    = true;
     requestReturned = true;
 }
コード例 #7
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Successful added a login!");
     GetStats();    // Load our stats
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userPassword);
     addLoginPanel.SetActive(false);
 }
コード例 #8
0
 private void OnAddLoginSucess(AddUsernamePasswordResult result)
 {
     Debug.Log("Congratulations, you made your first successful API call!");
     //on success save to playerprefs so user doesnt have to login each time.
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userPassword);
     // loginPanel.SetActive(false);
     addLoginPanel.SetActive(false);
 }
コード例 #9
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("On<color=red>Register</color>Success: Congratulations, you made your first successful API call!");
     // This is what remembers your email and Password.
     PlayerPrefs.SetString("EMAIL", userEmail);
     PlayerPrefs.SetString("PASSWORD", userPassword);
     GetStats();         //Gets the stats from the server..?  Sure.  Why not?  The tut was not clear as to the gain.  If it messes stuff up, this is the first thing to get commented out.
     addLoginPanel.SetActive(false);
 }
コード例 #10
0
    private void CreatedEmail(AddUsernamePasswordResult result)
    {
        //localStorage.SetPrefLoggedInCustomID ();
        // User Custom ID is known check if they have email created
        localStorage.SetPrefLoggedInCustomIDandEmail();
        uxPlayFab.HideAllPopups();

        // good to go!
        CheckRights();
    }
コード例 #11
0
 private void OnAddUserSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Congratulations, new user have been created successfully!");
     if (validEmail && rememberMe)
     {
         PlayerPrefs.SetString("EMAIL", userEmail.text);
         PlayerPrefs.SetString("PASSWORD", userPassword.text);
         PlayerPrefs.SetInt("LOGINONCE", 1);
     }
     LoadSceneOnLoginSuccess();
 }
コード例 #12
0
    private void OnLinkAccountSuccess(AddUsernamePasswordResult result)
    {
        Debug.Log("Account Linked Succesfull!");
        PlayerPrefs.SetString("EMAIL", PlayfabSingleton.instance.userEmail);
        PlayerPrefs.SetString("PASSWORD", PlayfabSingleton.instance.userPassword);

        PlayfabSingleton.instance.OnLoginSuccess();

        UISingleton.instance.loginPanel.SetActive(false);
        UISingleton.instance.logoutButton.SetActive(true);
    }
コード例 #13
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Successfully Added Info To Anonymous Account");
     PlayerPrefs.SetString("EMAIL", userEmailStr);
     PlayerPrefs.SetString("PASSWORD", userPassStr);
     networkController.userEmailGO.SetActive(false);
     networkController.userNameGO.SetActive(false);
     networkController.userPassGO.SetActive(false);
     networkController.submitRecovery.SetActive(false);
     networkController.loginButton.SetActive(false);
     networkController.submitButton.SetActive(false);
     networkController.onlineButton.SetActive(true);
     WipeTextFields();
 }
コード例 #14
0
    private void addloginrequestsuccess(AddUsernamePasswordResult result)
    {
        Debug.Log("Congratulations, you made your first successful API call!");
        PlayerPrefs.SetString("USERNAME", username);
        PlayerPrefs.SetString("PASSWORD", userpassword);
        PlayFabClientAPI.UpdateUserTitleDisplayName(
            new UpdateUserTitleDisplayNameRequest {
            DisplayName = username
        },
            displaynamesuccess,
            addloginreuestfailure);

        Addloginpanel.SetActive(false);
        RecoverButton.SetActive(false);
    }
コード例 #15
0
    public void RegisterSuccess(AddUsernamePasswordResult result)
    {
        Debug.Log("Register Sucess!");
        proceed = false;

        /*UpdateUserTitleDisplayNameRequest request = new UpdateUserTitleDisplayNameRequest ();
         * if (PlayerName.Length > 0) {
         *      request.DisplayName = PlayerName;
         * } else {
         *      request.DisplayName = UserName;
         * }
         * //use link PlayFabClientAPI.UpdateUserTitleDisplayName (request, LinkAccount, OnPlayFabError);
         * PlayFabClientAPI.UpdateUserTitleDisplayName (request, NameUpdated, OnPlayFabError);
         * //LoadingCanvas.enabled = true;*/
        NameUpdated(null);
        ShowLoading();
    }
コード例 #16
0
ファイル: PlayFabConnect.cs プロジェクト: Shahdee/pele
    void OnAddCredentialsSuccess(AddUsernamePasswordResult result)
    {
        Debug.Log("OnAddCredentialsSuccess ");

        OnAddCredentialsSuccess();
    }
コード例 #17
0
 private void OnAddLoginSuccess(AddUsernamePasswordResult result)
 {
     Debug.Log("Succesfully Linked!");
 }
コード例 #18
0
    private void OnAddUsernamePasswordSuccess(AddUsernamePasswordResult result)
    {
        var prevRequest = (AddUsernamePasswordRequest)result.Request;

        Debug.Log("Username: "******" with Email:" + prevRequest.Email + " has been created successfully");
    }
コード例 #19
0
using System.Collections.Generic;
using Photon.Pun;
using PlayFab;
using PlayFab.ClientModels;
using PlayFab.Json;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayFabController : MonoBehaviour
{
    public static PlayFabController PFC;

    private string userEmail;
    private string userPassword;
    private string username;
    public GameObject loginPanel;
    public GameObject addLoginPanel;
    public GameObject recoverButton;
    public SceneManager SM;

    private void OnEnable() {
        if (PlayFabController.PFC == null) {
            PlayFabController.PFC = this;
        }
        else { 
            if (PlayFabController.PFC != this) {
                Destroy(this.gameObject);
            }
        }
        DontDestroyOnLoad(this.gameObject);
    }

    public void Start()
    {
        //Used currently to counteract the autologin setting
        PlayerPrefs.DeleteAll();

        //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "E5D9";
        }
        //var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
        //PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);


        if (PlayerPrefs.HasKey("EMAIL"))
        {
            userEmail = PlayerPrefs.GetString("EMAIL");
            userPassword = PlayerPrefs.GetString("PASSWORD");
            var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
        }
        else {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest { AndroidDeviceId = returnMobileID(), CreateAccount = true };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest { DeviceId = returnMobileID(), CreateAccount = true };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
        }
              
    }

    #region Login
    private void OnLoginSuccess(LoginResult result)
    {
        Debug.Log("Login Success!");
        PlayerPrefs.SetString("EMAIL", userEmail);
        PlayerPrefs.SetString("PASSWORD", userPassword);
        loginPanel.SetActive(false);
        getStats();

        //Move the camera to reveal database and launch options
        var moveScript = GameObject.Find("Main Camera").GetComponent<CameraMove>();
        moveScript.MoveBack();
    }

    private void OnLoginMobileSuccess(LoginResult result)
    {
        Debug.Log("Mobile Login Success!");
        getStats();
        loginPanel.SetActive(false);

        //Move the camera to reveal the new input options
        var moveScript = GameObject.Find("Main Camera").GetComponent<CameraMove>();
        moveScript.MoveBack();
    }

    private void onRegisterSuccess(RegisterPlayFabUserResult result) {
        Debug.Log("Registration Success!");
        PlayerPrefs.SetString("EMAIL", userEmail);
        PlayerPrefs.SetString("PASSWORD", userPassword);

        PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest { DisplayName = username }, OnDisplayName, OnLoginMobileFailure);
        getStats();
        loginPanel.SetActive(false);

        //Move the camera to reveal the new input options
        var moveScript = GameObject.Find("Main Camera").GetComponent<CameraMove>();
        moveScript.MoveBack();
    }

    void OnDisplayName(UpdateUserTitleDisplayNameResult result) {
        Debug.Log(result.DisplayName + " is your new display name");
    }

    private void OnLoginFailure(PlayFabError error)
    {
        var registerRequest = new RegisterPlayFabUserRequest { Email = userEmail, Password = userPassword, Username = username};
        PlayFabClientAPI.RegisterPlayFabUser(registerRequest, onRegisterSuccess, onRegisterFailure);
    }

    private void OnLoginMobileFailure(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }

    private void onRegisterFailure(PlayFabError error) {
        Debug.LogError(error.GenerateErrorReport());
    }

    public void GetUserEmail(string emailIn) {
        userEmail = emailIn;
    }

    public void getUserPassword(string passwordIn) {
        userPassword = passwordIn;
    }

    public void getUsername(string usernameIn) {
        username = usernameIn;
    }

    public void onClickLogin() {
        var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword };
        PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
    }

    public static string returnMobileID() {
        string deviceID = SystemInfo.deviceUniqueIdentifier;
        return deviceID;
    }

    public void openAddLogin() {
        addLoginPanel.SetActive(true);

        //Move the camera to reveal the new input options
        var moveScript = GameObject.Find("Main Camera").GetComponent<CameraMove>();
        moveScript.MoveForward();
    }

    public void onClickAddLogin() {
        addLoginPanel.SetActive(false);

        var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword };
        PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
    }

    private void onAddLoginSuccess(AddUsernamePasswordResult result)
    {
        Debug.Log("Login Success!");
        PlayerPrefs.SetString("EMAIL", userEmail);
        PlayerPrefs.SetString("PASSWORD", userPassword);
        getStats();
        addLoginPanel.SetActive(false);

        //Move the camera to reveal the new input options
        var moveScript = GameObject.Find("Main Camera").GetComponent<CameraMove>();
        moveScript.MoveBack();
    }
    #endregion Login

    #region PlayerStats

    public int playerKillCount;

    public void setStats() { 
        PlayFabClientAPI.UpdatePlayerStatistics( new UpdatePlayerStatisticsRequest {
            // request.Statistics is a list, so multiple StatisticUpdate objects can be defined if required.
            Statistics = new List<StatisticUpdate> {
            new StatisticUpdate { StatisticName = "PlayerKillCount", Value = playerKillCount }
            }
        },
        result => { Debug.Log("User statistics updated"); },
        error => { Debug.LogError(error.GenerateErrorReport()); });
    }

    void getStats() {
        PlayFabClientAPI.GetPlayerStatistics(
            new GetPlayerStatisticsRequest(),
            OnGetStatistics,
            error => Debug.LogError(error.GenerateErrorReport())
        );
    }

    void OnGetStatistics(GetPlayerStatisticsResult result)
    {
        Debug.Log("Received the following Statistics:");
        foreach (var eachStat in result.Statistics)
        {
            Debug.Log("Statistic (" + eachStat.StatisticName + "): " + eachStat.Value);
            switch(eachStat.StatisticName) {
                case "PlayerKillCount":
                    playerKillCount = eachStat.Value;
                    break;
            }
        }
    }

    // Build the request object and access the API
    public void StartCloudUpdatePlayerStats()
    {
        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName = "UpdatePlayerStats", // Arbitrary function name (must exist in your uploaded cloud.js file)
            FunctionParameter = new { pKillCount = playerKillCount}, // The parameter provided to your function
            GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream
        }, OnCloudUpdateStats, OnErrorShared);
    }


    private static void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult));
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object messageValue;
        jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in Cloud Script
        Debug.Log((string)messageValue);
    }

    private static void OnErrorShared(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }

    #endregion PlayerStats


    public GameObject leaderboardPanel;
    public GameObject listingPrefab;
    public Transform listingContainer;

    #region Leaderboard
    public void GetLeaderboard() {
        var requestLeaderboard = new GetLeaderboardRequest { StartPosition = 0, StatisticName = "PlayerKillCount", MaxResultsCount = 20 };
        PlayFabClientAPI.GetLeaderboard(requestLeaderboard, onGetLeaderboard, onErrorLeaderboard);
    }

    void onGetLeaderboard(GetLeaderboardResult result) {
        leaderboardPanel.SetActive(true);
        //Debug.Log(result.Leaderboard[0].StatValue);
        foreach(PlayerLeaderboardEntry player in result.Leaderboard) {
            GameObject tempListing = Instantiate(listingPrefab, listingContainer);
            LeaderboardListing LL = tempListing.GetComponent<LeaderboardListing>();
            LL.playerNameText.text = player.DisplayName;
            LL.playerScoreText.text = player.StatValue.ToString();
            Debug.Log(player.DisplayName + ": " + player.StatValue);
        }
    }

    public void closeLeaderboardPanel() {
        leaderboardPanel.SetActive(false);
        for(int i = listingContainer.childCount - 1; i >= 0; i--) {
            Destroy(listingContainer.GetChild(i).gameObject);
        }
    }

    void onErrorLeaderboard(PlayFabError error) {
        Debug.LogError(error.GenerateErrorReport());
    }

    #endregion Leaderboard



    #region Friends

    string friendUsername;

    enum FriendIdType { PlayFabId, Username, Email, DisplayName };

    void AddFriend(FriendIdType idType, string friendId)
    {
        var request = new AddFriendRequest();
        switch (idType)
        {
            case FriendIdType.PlayFabId:
                request.FriendPlayFabId = friendId;
                break;
            case FriendIdType.Username:
                request.FriendUsername = friendId;
                break;
            case FriendIdType.Email:
                request.FriendEmail = friendId;
                break;
            case FriendIdType.DisplayName:
                request.FriendTitleDisplayName = friendId;
                break;
        }
        // Execute request and update friends when we are done
        PlayFabClientAPI.AddFriend(request, result => {
            Debug.Log("Friend added successfully!");
        }, DisplayPlayFabError);
    }

    List<FriendInfo> _friends = null;

    void GetFriends()
    {
        PlayFabClientAPI.GetFriendsList(new GetFriendsListRequest
        {
            IncludeSteamFriends = false,
            IncludeFacebookFriends = false
        }, result => {
            _friends = result.Friends;
            DisplayFriends(_friends); // triggers your UI
        }, DisplayPlayFabError);
    }

    void DisplayFriends(List<FriendInfo> friendsCache) { friendsCache.ForEach(f => Debug.Log(f.Username)); }
    void DisplayPlayFabError(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); }
    void DisplayError(string error) { Debug.LogError(error); }

    public void OnClickAddFriend() {
        AddFriend(FriendIdType.Username, friendUsername);
    }

    public void setFriendUsername(string value) {
        friendUsername = value;
    }

    #endregion Friends
}

コード例 #20
0
 /// <summary>
 /// Successfunction, called when the username and password are successfully added in PlayFab
 /// </summary>
 /// <param name="result"></param>
 private void AddUsernameSuccess(AddUsernamePasswordResult result)
 {
     GameObject.FindGameObjectWithTag("SavedEmailAddressSuccess").GetComponent <ShowInfoText>().ShowToast(3);
     creditClass.AddCredits(100);
     RefreshAccountStats();
 }