Esempio n. 1
0
    void Authenticate()
    {
        if (IsAuthenticated())
        {
            return;
        }

        Debug.Log("Social.localUser.Authenticate");

        EnableLoadingOverlay(true);
        m_State = GooglePlayState.AUTHENTICATING;

        // authenticate user:
        Social.localUser.Authenticate(( bool success ) =>
        {
            // handle success or failure
            Debug.Log("Social.localUser.Authenticate success - " + success);
            if (success)
            {
                m_State = GooglePlayState.CHECK_AUTH;
            }
            else
            {
                m_State = GooglePlayState.FAIL_AUTH;
                ++s_Retry;
                EnableLoadingOverlay(false);
            }
        });
    }
Esempio n. 2
0
    void Initialise()
    {
        if (!s_Initialised)
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
                                                  // enables saving game progress.
                                                  //.EnableSavedGames()
                                                  // registers a callback to handle game invitations received while the game is not running.
                                                  //.WithInvitationDelegate(< callback method >)
                                                  // registers a callback for turn based match notifications received while the
                                                  // game is not running.
                                                  //.WithMatchDelegate(< callback method >)
                                                  // requests the email address of the player be available.
                                                  // Will bring up a prompt for consent.
                                                  //.RequestEmail()
                                                  // requests a server auth code be generated so it can be passed to an
                                                  //  associated back end server application and exchanged for an OAuth token.
                                                  //.RequestServerAuthCode( false )
                                                  // requests an ID token be generated.  This OAuth token can be used to
                                                  //  identify the player to other services such as Firebase.
                                                  //.RequestIdToken()
                                                  .Build();

            PlayGamesPlatform.InitializeInstance(config);

            // recommended for debugging:
            PlayGamesPlatform.DebugLogEnabled = true;
            // Activate the Google Play Games platform
            PlayGamesPlatform.Activate();

            s_Initialised = true;
            m_State       = GooglePlayState.START_AUTH;
            m_QueueState  = GooglePlayState.NONE;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        switch (m_State)
        {
        case GooglePlayState.START_AUTH:
            Authenticate();
            break;

        case GooglePlayState.AUTHENTICATING:
            // Nothing
            break;

        case GooglePlayState.CHECK_AUTH:
            if (IsAuthenticated())
            {
                EnableLoadingOverlay(false);
                ResumeState();
            }
            else
            {
                // Wait
            }
            break;

        case GooglePlayState.FAIL_AUTH:
            if (m_QueueState != GooglePlayState.NONE)
            {
                // Show popup
                Popup popup = Popup.GetPopup();
                if (popup)
                {
                    popup.ShowPopup("Failed to connect to Google Play.");
                }

                m_QueueState = GooglePlayState.NONE;
            }

            m_State = GooglePlayState.NONE;
            break;

        case GooglePlayState.SHOWING_ACHIEVEMENT:
            ShowAchievementUI();
            break;

        case GooglePlayState.SHOWING_LEADERBOARD:
            ShowLeaderboardUI();
            break;

        default:
            // Idle
            break;
        }
    }
Esempio n. 4
0
    void ShowAchievementUI()
    {
        if (!IsAuthenticated())
        {
            PauseState(GooglePlayState.START_AUTH);
            Authenticate();
        }
        else
        {
            Debug.Log("Social.ShowAchievementsUI()");
            MainMenuManager.DisableButtons();
            PlayGamesPlatform.Instance.ShowAchievementsUI(EnableButtons);

            m_State = GooglePlayState.NONE;
        }
    }
Esempio n. 5
0
    void ShowLeaderboardUI()
    {
        if (!IsAuthenticated())
        {
            PauseState(GooglePlayState.START_AUTH);
            Authenticate();
        }
        else
        {
            Debug.Log("Social.ShowLeaderboardUI()");
            MainMenuManager.DisableButtons();
            PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_high_score, EnableButtons);

            m_State = GooglePlayState.NONE;
        }
    }
Esempio n. 6
0
 public void StartShowAchievementUI()
 {
     m_State = GooglePlayState.SHOWING_ACHIEVEMENT;
 }
Esempio n. 7
0
 void PauseState(GooglePlayState goState)
 {
     m_QueueState = m_State;
     m_State      = goState;
 }
Esempio n. 8
0
 void ResumeState()
 {
     m_State      = m_QueueState;
     m_QueueState = GooglePlayState.NONE;
 }
Esempio n. 9
0
 public void StartShowLeaderboardUI()
 {
     m_State = GooglePlayState.SHOWING_LEADERBOARD;
 }