Пример #1
0
        /// <summary>
        /// Loads the user data from the Fizzyo API.
        ///
        /// PlayerPrefs holds the users information in the following configuration:
        ///
        /// "online" - Integer - 0 or 1 - Tells the developer if the user is playing offline or online
        ///
        /// "calDone" - Integer - 0 or 1 - Tells the developer if the user has completed calibration
        ///
        /// "achievements" - String - Holds the achievements for the game and, if the user is online, tells the developer
        /// which achievements have been unlocked
        ///
        /// "achievementsToUpload" - String - Holds the achievements that have been unlocked in the current session
        ///
        /// Current players userID + "AchievementProgress" - String - Holds data on the achievement progress that the user has made in this game
        ///
        /// "accessToken" - String - Holds the access token that is aquired for the current user
        ///
        /// "tagDone" - Integer - 0 or 1 - Tells the developer if the user has completed setting a tag
        ///
        /// "userTag" - String - Holds the user tag
        ///
        /// "calPressure" - Float - Holds the pressure that the user has set in their calibration
        ///
        /// "calTime" - Integer - Holds the breath length that the user has set in their calibration
        ///
        /// "userId" - String - Holds the user Id that is aquired for the current user
        ///
        /// "gameId" - String - Holds the game Id for this specific game
        ///
        /// "gameSecret" - String - Holds the game secret for this specific game
        ///
        /// "userLoaded" - Integer - 0 or 1 - Shows if the users access token was loaded
        ///
        /// "calLoaded" - Integer - 0 or 1 - Shows if the users calibration data was loaded
        ///
        /// "achLoaded" - Integer - 0 or 1 - Shows if the users achievement data was loaded
        ///
        /// "tagLoaded" - Integer - 0 or 1 - Shows if the users tag was loaded
        ///
        /// </summary>
        /// <param name="gameId">String that contains the current games ID </param>
        /// <param name="gameSecret">String that contains the current games secret</param>
        /// <returns>
        /// true if data is loaded and playing online
        ///
        /// false if data is not loaded and playing offline
        /// </returns>
        public bool Load()
        {
            //Login to server

            if (showLoginAutomatically)
            {
                LoginReturnType loginResult = User.Login();


                if (loginResult != LoginReturnType.SUCCESS)
                {
                    PlayOffline();
                    return(false);
                }
            }
            else
            {
                PlayOffline();
                return(false);
            }

            User.Load();
            Achievements.Load();



            return(true);
        }
Пример #2
0
        /// <summary>
        /// Loads the user data from the Fizzyo API.
        ///
        /// PlayerPrefs holds the users information in the following configuration:
        ///
        /// "online" - Integer - 0 or 1 - Tells the developer if the user is playing offline or online
        ///
        /// "calDone" - Integer - 0 or 1 - Tells the developer if the user has completed calibration
        ///
        /// "achievements" - String - Holds the achievements for the game and, if the user is online, tells the developer
        /// which achievements have been unlocked
        ///
        /// "achievementsToUpload" - String - Holds the achievements that have been unlocked in the current session
        ///
        /// Current players userID + "AchievementProgress" - String - Holds data on the achievement progress that the user has made in this game
        ///
        /// "accessToken" - String - Holds the access token that is aquired for the current user
        ///
        /// "tagDone" - Integer - 0 or 1 - Tells the developer if the user has completed setting a tag
        ///
        /// "userTag" - String - Holds the user tag
        ///
        /// "calPressure" - Float - Holds the pressure that the user has set in their calibration
        ///
        /// "calTime" - Integer - Holds the breath length that the user has set in their calibration
        ///
        /// "userId" - String - Holds the user Id that is aquired for the current user
        ///
        /// "gameId" - String - Holds the game Id for this specific game
        ///
        /// "gameSecret" - String - Holds the game secret for this specific game
        ///
        /// "userLoaded" - Integer - 0 or 1 - Shows if the users access token was loaded
        ///
        /// "calLoaded" - Integer - 0 or 1 - Shows if the users calibration data was loaded
        ///
        /// "achLoaded" - Integer - 0 or 1 - Shows if the users achievement data was loaded
        ///
        /// "tagLoaded" - Integer - 0 or 1 - Shows if the users tag was loaded
        ///
        /// </summary>
        /// <param name="gameId">String that contains the current games ID </param>
        /// <param name="gameSecret">String that contains the current games secret</param>
        /// <returns>
        /// true if data is loaded and playing online
        ///
        /// false if data is not loaded and playing offline
        /// </returns>
        public bool Load()
        {
            //Login to server
#if UNITY_UWP
            ClientVersion = SystemInfo.deviceUniqueIdentifier;
#endif
            if (showLoginAutomatically)
            {
                LoginReturnType loginResult = FizzyoFramework.Instance.User.Login();


                if (loginResult != LoginReturnType.SUCCESS)
                {
                    PlayOffline();
                    return(false);
                }
            }
            else
            {
                PlayOffline();
                return(false);
            }

            FizzyoFramework.Instance.User.Load();
            FizzyoFramework.Instance.Achievements.Load();
            FizzyoFramework.Instance.Analytics.Start();
            FizzyoFramework.Instance.Analytics.UploadCache();



            return(true);
        }
Пример #3
0
        public async Task LoginAsync()
        {
            string authorizationRequest = String.Format("{0}?client_id={1}&scope={2}&response_type=code&redirect_uri={3}",
                                                        authorizationEndpoint,
                                                        clientID,
                                                        //state,
                                                        scopes,
                                                        System.Uri.EscapeDataString(redirectURI));

            Uri StartUri = new Uri(authorizationRequest);
            Uri EndUri   = new Uri(redirectURI);



            WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, StartUri, EndUri);

            if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
            {
                Uri    authorizationResponse = new Uri(WebAuthenticationResult.ResponseData.ToString());
                string queryString           = authorizationResponse.Query;
                Dictionary <string, string> queryStringParams =
                    queryString.Substring(1).Split('&')
                    .ToDictionary(c => c.Split('=')[0],
                                  c => Uri.UnescapeDataString(c.Split('=')[1]));
                // Gets the Authorization code
                String code = queryStringParams["code"];

                // Authorization Code is now ready to use!



                bool tokenExhanged = await RequestAccessToken(code);

                if (tokenExhanged == true)
                {
                    loginResult     = LoginReturnType.SUCCESS;
                    loginInProgress = false;
                    return;
                }
                else
                {
                    loginResult     = LoginReturnType.INCORRECT;
                    loginInProgress = false;
                    return;
                }
            }

            loginResult     = LoginReturnType.FAILED_TO_CONNECT;
            loginInProgress = false;
            return;
        }
Пример #4
0
        /// <summary>
        /// Loads the user data from the Fizzyo API.
        ///
        /// PlayerPrefs holds the users information in the following configuration:
        ///
        /// "online" - Integer - 0 or 1 - Tells the developer if the user is playing offline or online
        ///
        /// "calDone" - Integer - 0 or 1 - Tells the developer if the user has completed calibration
        ///
        /// "achievements" - String - Holds the achievements for the game and, if the user is online, tells the developer
        /// which achievements have been unlocked
        ///
        /// "achievementsToUpload" - String - Holds the achievements that have been unlocked in the current session
        ///
        /// Current players userID + "AchievementProgress" - String - Holds data on the achievement progress that the user has made in this game
        ///
        /// "accessToken" - String - Holds the access token that is acquired for the current user
        ///
        /// "tagDone" - Integer - 0 or 1 - Tells the developer if the user has completed setting a tag
        ///
        /// "userTag" - String - Holds the user tag
        ///
        /// "calPressure" - Float - Holds the pressure that the user has set in their calibration
        ///
        /// "calTime" - Integer - Holds the breath length that the user has set in their calibration
        ///
        /// "userId" - String - Holds the user Id that is acquired for the current user
        ///
        /// "gameId" - String - Holds the game Id for this specific game
        ///
        /// "gameSecret" - String - Holds the game secret for this specific game
        ///
        /// "userLoaded" - Integer - 0 or 1 - Shows if the users access token was loaded
        ///
        /// "calLoaded" - Integer - 0 or 1 - Shows if the users calibration data was loaded
        ///
        /// "achLoaded" - Integer - 0 or 1 - Shows if the users achievement data was loaded
        ///
        /// "tagLoaded" - Integer - 0 or 1 - Shows if the users tag was loaded
        ///
        /// </summary>
        /// <param name="gameId">String that contains the current games ID </param>
        /// <param name="gameSecret">String that contains the current games secret</param>
        /// <returns>
        /// true if data is loaded and playing online
        ///
        /// false if data is not loaded and playing offline
        /// </returns>
        public bool Load()
        {
            //Login to server
            if (FizzyoConfigurationProfile != null && FizzyoConfigurationProfile.ShowLoginAutomatically)
            {
                LoginReturnType loginResult = User.Login();

                if (loginResult != LoginReturnType.SUCCESS)
                {
                    PlayOffline();
                    return(false);
                }
            }
            else
            {
                PlayOffline();
                return(false);
            }

            User.Load();
            Achievements.Load();

            return(true);
        }