Example #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode,
                                                 Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            switch (requestCode)
            {
            case RC_SELECT_PLAYERS:
                // we got the result from the "select players" UI -- ready to create the room
                HandleSelectPlayersResult(resultCode, data);
                break;

            case RC_INVITATION_INBOX:
                // we got the result from the "select invitation" UI (invitation inbox). We're
                // ready to accept the selected invitation:
                HandleInvitationInboxResult(resultCode, data);
                break;

            case RC_WAITING_ROOM:
                // we got the result from the "waiting room" UI.
                if (resultCode == Result.Ok)
                {
                    // ready to start playing
                    Log.Debug(TAG, "Starting game (waiting room returned OK).");
                    StartGame(true);
                }
                else if ((int)resultCode == GamesActivityResultCodes.ResultLeftRoom)
                {
                    // player indicated that they want to leave the room
                    LeaveRoom();
                }
                else if (resultCode == Result.Canceled)
                {
                    // Dialog was cancelled (user pressed back key, for instance). In our game,
                    // this means leaving the room too. In more elaborate games, this could mean
                    // something else (like minimizing the waiting room UI).
                    LeaveRoom();
                }
                break;

            case RC_SIGN_IN:
                Log.Debug(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode=" +
                          resultCode + ", intent=" + data);
                mSignInClicked = false;
                mResolvingConnectionFailure = false;
                if (resultCode == Result.Ok)
                {
                    mGoogleApiClient.Connect();
                }
                else
                {
                    BaseGameUtils.ShowActivityResultError(this, requestCode, (int)resultCode, Resource.String.signin_other_error);
                }
                break;
            }
            base.OnActivityResult(requestCode, resultCode, data);
        }
Example #2
0
        public void OnConnectionFailed(ConnectionResult connectionResult)
        {
            Log.Debug(TAG, "onConnectionFailed() called, result: " + connectionResult);

            if (mResolvingConnectionFailure)
            {
                Log.Debug(TAG, "onConnectionFailed() ignoring connection failure; already resolving.");
                return;
            }

            if (mSignInClicked || mAutoStartSignInFlow)
            {
                mAutoStartSignInFlow        = false;
                mSignInClicked              = false;
                mResolvingConnectionFailure = BaseGameUtils.ResolveConnectionFailure(this, mGoogleApiClient,
                                                                                     connectionResult, RC_SIGN_IN, GetString(Resource.String.signin_other_error));
            }

            SwitchToScreen(Resource.Id.screen_sign_in);
        }
Example #3
0
 // Show error message about game being cancelled and return to main screen.
 void ShowGameError()
 {
     BaseGameUtils.MakeSimpleDialog(this, GetString(Resource.String.game_problem));
     SwitchToMainScreen();
 }