/// <summary>
    /// Determines if the current platform can use a specific service path.
    /// </summary>
    /// <returns><c>true</c> if service can be used on the current platform; otherwise, <c>false</c>.</returns>
    /// <param name="path">Path.</param>
    public static bool CanUseService(PlayFabLoginCalls.LoginPathways path)
    {
        switch (path)
        {
        case LoginPathways.deviceId:
            return(CheckForSupportedMobilePlatform());

        case LoginPathways.facebook:
            return(CheckForSupportedMobilePlatform());

        case LoginPathways.steam:
            if (Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.WindowsPlayer)
            {
                // need additional checks here once the steamworks API is integrated
                return(true);
            }
            break;

        case LoginPathways.gameCenter:
            if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                return(true);
            }
            break;

        case LoginPathways.pf_email:
            return(true);

        case LoginPathways.pf_username:
            return(true);
        }
        return(false);
    }
 void AutoNewAccount()
 {
     this.status.text = "No previous login found...";
     this.details.text = "Using device id (if available)...\nclick below to manually change accounts";
     this.createNewAccount = false;
     this.autoLoginAfter *= 1.5f;
     EnableCountdown();
     this.loginPathToUse = PlayFabLoginCalls.LoginPathways.deviceId;
 }
 void AutoNewAccount()
 {
     this.status.text      = "No previous login found...";
     this.details.text     = "Using device id (if available)...\nclick below to manually change accounts";
     this.createNewAccount = false;
     this.autoLoginAfter  *= 1.5f;
     EnableCountdown();
     this.loginPathToUse = PlayFabLoginCalls.LoginPathways.deviceId;
 }
    /// <summary>
    /// Parses Unity PlayerPrefs for saved login information. See the gitHub readme for more information
    /// </summary>
    /// <returns> used for coroutine yielding </returns>
    IEnumerator ReadLoginDataRecord()
    {
        this.status.text = "Finding previous logins...";

        if(PlayerPrefs.HasKey("loginMethodUsed"))
        {
            this.status.text = "Previous login found... ";
            string raw = PlayerPrefs.GetString("loginMethodUsed");

            PlayFabLoginCalls.LoginPathways method = (PlayFabLoginCalls.LoginPathways) Enum.Parse(typeof(PlayFabLoginCalls.LoginPathways), raw);
            Debug.Log(method.ToString());

            switch(method)
            {
                case PlayFabLoginCalls.LoginPathways.pf_username:
                    if(PlayerPrefs.HasKey("accountInfo"))
                    {
                    this.accountInfo =  JsonConvert.DeserializeObject<UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                        this.createNewAccount = false;
                        PrompForPassword();
                        this.details.text = string.Format("PlayFab Username: {0} found...", this.accountInfo.Username);
                        this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.pf_username;
                    }
                    break;

                case PlayFabLoginCalls.LoginPathways.pf_email:
                    if(PlayerPrefs.HasKey("accountInfo"))
                    {
                        this.accountInfo =  JsonConvert.DeserializeObject<UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                        this.createNewAccount = false;
                        PrompForPassword();
                        this.details.text = string.Format("Email: {0} found...", this.accountInfo.PrivateInfo.Email);
                        this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.pf_email;
                    }
                    break;

                case PlayFabLoginCalls.LoginPathways.deviceId:
                        EnableCountdown();
                        this.createNewAccount = false;
                        this.details.text = "Device Id, click below to manually change accounts";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.deviceId;
                    break;

                case PlayFabLoginCalls.LoginPathways.facebook:
                        EnableCountdown();
                        this.createNewAccount = false;
                        this.details.text = "Facebook, click below to manually change accounts";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.facebook;
                    break;

                case PlayFabLoginCalls.LoginPathways.gameCenter:
                        EnableCountdown();
                        this.createNewAccount = false;
                        this.details.text = "GameCenter, click below to manually change accounts";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.gameCenter;
                    break;

                case PlayFabLoginCalls.LoginPathways.googlePlus:
                        EnableCountdown();
                        this.createNewAccount = false;
                        this.details.text = "Google+, click below to manually change accounts";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.googlePlus;
                    break;

                case PlayFabLoginCalls.LoginPathways.steam:
                        EnableCountdown();
                        this.createNewAccount = false;
                        this.details.text = "Steam, click below to manually change accounts";
                        this.loginPathToUse = PlayFabLoginCalls.LoginPathways.steam;
                    break;
                default:
                    AutoNewAccount();
                break;
            }
        }
        else
        {
            if(PlayFabLoginCalls.CheckForSupportedMobilePlatform())
            {
                AutoNewAccount();
            }
            else
            {
                PlayFabLoginCalls.TestDeviceIdHasAccount();
                yield return new WaitForSeconds(.333f);
                authController.activeState = AuthenticationController.LoginStates.Manual;
            }
        }
    }
    /// <summary>
    /// Parses Unity PlayerPrefs for saved login information. See the gitHub readme for more information
    /// </summary>
    /// <returns> used for coroutine yielding </returns>
    IEnumerator ReadLoginDataRecord()
    {
        this.status.text = "Finding previous logins...";

        if (PlayerPrefs.HasKey("loginMethodUsed"))
        {
            this.status.text = "Previous login found... ";
            string raw = PlayerPrefs.GetString("loginMethodUsed");

            PlayFabLoginCalls.LoginPathways method = (PlayFabLoginCalls.LoginPathways)Enum.Parse(typeof(PlayFabLoginCalls.LoginPathways), raw);
            Debug.Log(method.ToString());

            switch (method)
            {
            case PlayFabLoginCalls.LoginPathways.pf_username:
                if (PlayerPrefs.HasKey("accountInfo"))
                {
                    this.accountInfo      = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                    this.createNewAccount = false;
                    PrompForPassword();
                    this.details.text      = string.Format("PlayFab Username: {0} found...", this.accountInfo.Username);
                    this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                    this.loginPathToUse    = PlayFabLoginCalls.LoginPathways.pf_username;
                }
                break;

            case PlayFabLoginCalls.LoginPathways.pf_email:
                if (PlayerPrefs.HasKey("accountInfo"))
                {
                    this.accountInfo      = JsonConvert.DeserializeObject <UserAccountInfo>(PlayerPrefs.GetString("accountInfo"));
                    this.createNewAccount = false;
                    PrompForPassword();
                    this.details.text      = string.Format("Email: {0} found...", this.accountInfo.PrivateInfo.Email);
                    this.instructions.text = "Enter password to continue, or change accounts manually by clicking below.";
                    this.loginPathToUse    = PlayFabLoginCalls.LoginPathways.pf_email;
                }
                break;

            case PlayFabLoginCalls.LoginPathways.deviceId:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Device Id, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.deviceId;
                break;

            case PlayFabLoginCalls.LoginPathways.facebook:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Facebook, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.facebook;
                break;

            case PlayFabLoginCalls.LoginPathways.gameCenter:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "GameCenter, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.gameCenter;
                break;

            case PlayFabLoginCalls.LoginPathways.googlePlus:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Google+, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.googlePlus;
                break;

            case PlayFabLoginCalls.LoginPathways.steam:
                EnableCountdown();
                this.createNewAccount = false;
                this.details.text     = "Steam, click below to manually change accounts";
                this.loginPathToUse   = PlayFabLoginCalls.LoginPathways.steam;
                break;

            default:
                AutoNewAccount();
                break;
            }
        }
        else
        {
            if (PlayFabLoginCalls.CheckForSupportedMobilePlatform())
            {
                AutoNewAccount();
            }
            else
            {
                PlayFabLoginCalls.TestDeviceIdHasAccount();
                yield return(new WaitForSeconds(.333f));

                authController.activeState = AuthenticationController.LoginStates.Manual;
            }
        }
    }