Exemple #1
0
        public override void Authenticate(Action <bool> _onCompletion)
        {
            base.Authenticate(_onCompletion);

            // Request authentication
            m_localUserData.Authenticate(OnAuthenticationFinish);
        }
Exemple #2
0
    // Note: To pass a specific leaderboard and not the default leaderboard, pass the leaderboard ID when calling that function
    // (ie: Social.ShowLeaderboardUI("LeaderboardID")). If you are building to Android, use the PlayGamesPlatform's function (ie:
    // PlayGamesPlatform.Instance.ShowLeaderboardUI("LeaderboardID")).

    #endregion

    #region ----------Score Submission

    //-----------------------------------------
    // Public Methods
    //-----------------------------------------

    public void SubmitScore(int score, string id)   // Call this method to submit a score only if the user has beaten their old high score.
    {
        // When calling this method, specify the score to submit and the ID of the leaderboard to submit the score to.
        // This will work for both iOS and Android devices.

        // Tasks:
        // Check if the player is authenticated and submit the score to the leaderboard
        // If the player is not authenticated, re-authenticate and try to submit the score again

        if (localUser.authenticated)
        {
            // Tasks:
            // Submit the score to the leaderboard
            // Create a new instance of the leaderboard

            Social.ReportScore(score, id, (bool success) =>
            {
                if (success)
                {
                    DisplayDebugLog("Score was successfully submitted to the leaderboard: " + id);
                    DisplayDebugLog("Score submitted by " + localUser.userName.ToString() + ": " + score.ToString());

                    CreateLeaderboardInstance();    // Call CreateLeaderboardInstance() again to re-evaluate the updated leaderboard and use the new leaderboard instance data to transfer to your in-game leaderboard
                }
            });

            DisplayDebugLog("Processing score submission...");
        }
        else
        {
            // Re-authenticate the user
            localUser.Authenticate((bool success) =>
            {
                DisplayDebugLog("Re-authenticating the player...");

                if (success)
                {
                    // Tasks:
                    // Submit the score to the leaderboard
                    // Create a new instance of the leaderboard

                    Social.ReportScore(score, id, (bool success) =>
                    {
                        if (success)
                        {
                            DisplayDebugLog("Score was successfully submitted to the leaderboard: " + id);
                            DisplayDebugLog("Score submitted by " + localUser.userName.ToString() + ": " + score.ToString());

                            CreateLeaderboardInstance();    // Call CreateLeaderboardInstance() again to re-evaluate the updated leaderboard and use the new leaderboard instance data to transfer to your in-game leaderboard
                        }
                    });
                }
                else
                {
                    DisplayDebugLog("Authentication failed. Score not submitted to the leaderboard.");
                }
            });
        }
    }
	/// <summary>
	/// Authenticates the given user.
	/// </summary>
	/// <param name="user">The user to authenticate.</param>
	/// <param name="callback">Callback.</param>
	public void Authenticate (ILocalUser user, Action<bool> callback)
	{
		user.Authenticate(
			success => {
				if (success) {
					_localUser = user as LumosUser;
				}

				if (callback != null) {
					callback(success);
				}
			});
	}
Exemple #4
0
    /// <summary>
    /// Authenticates the given user.
    /// </summary>
    /// <param name="user">The user to authenticate.</param>
    /// <param name="callback">Callback.</param>
    public void Authenticate(ILocalUser user, Action <bool> callback)
    {
        user.Authenticate(
            success => {
            if (success)
            {
                _localUser = user as LumosUser;
            }

            if (callback != null)
            {
                callback(success);
            }
        });
    }
 /// <summary>
 /// Authenticates the user.
 /// </summary>
 /// <param name="user">User.</param>
 /// <param name="callback">Callback.</param>
 /// <example>
 /// Example of usage:
 /// <code>
 /// CombuManager.platform.Authenticate (user, (bool success) => {
 ///    Debug.Log("Authenticate: " + success);
 /// });
 /// </code>
 /// </example>
 public virtual void Authenticate(ILocalUser user, System.Action <bool> callback)
 {
     if (!CombuManager.isInitialized)
     {
         throw new System.Exception("Combu Manager not initialized");
     }
     user.Authenticate((bool success) => {
         if (success)
         {
             _localUser = (User)user;
         }
         if (callback != null)
         {
             callback(success);
         }
     });
 }