当前位置: 首页>>代码示例>>Java>>正文


Java TurnBasedMatch类代码示例

本文整理汇总了Java中com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch的典型用法代码示例。如果您正苦于以下问题:Java TurnBasedMatch类的具体用法?Java TurnBasedMatch怎么用?Java TurnBasedMatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TurnBasedMatch类属于com.google.android.gms.games.multiplayer.turnbased包,在下文中一共展示了TurnBasedMatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);
	gameHelper.onActivityResult(requestCode, resultCode, data);

	if (requestCode == RC_LOOK_AT_MATCHES) {
		// Returning from the 'Select Match' dialog

		if (resultCode != Activity.RESULT_OK) {
			// user canceled
			return;
		}

		TurnBasedMatch match = data.getParcelableExtra(Multiplayer.EXTRA_TURN_BASED_MATCH);

		if (match.getData() == null)
		    startMatch(match);
		else
			updateMatch(match);

		Log.d(TAG, "Match = " + match);
	}

	
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:26,代码来源:AndroidLauncher.java

示例2: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void startMatch(TurnBasedMatch match) {
	System.out.println("Started match");

	mTurnData = new GameModelWrapper();

	mMatch = match;

	String playerId = Games.Players.getCurrentPlayerId(gameHelper.getApiClient());
	String myParticipantId = mMatch.getParticipantId(playerId);

	Games.TurnBasedMultiplayer.takeTurn(gameHelper.getApiClient(), match.getMatchId(),
			mTurnData.convertToByteArray(), myParticipantId).setResultCallback(
			new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
					processResult(result);
				}
			});
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:20,代码来源:AndroidLauncher.java

示例3: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void startMatch(TurnBasedMatch match) {
    mTurnData = new SkeletonTurn();
    // Some basic turn data
    mTurnData.data = "First turn";

    mMatch = match;

    String playerId = Games.Players.getCurrentPlayerId(mGoogleApiClient);
    String myParticipantId = mMatch.getParticipantId(playerId);

    showSpinner();

    Games.TurnBasedMultiplayer.takeTurn(mGoogleApiClient, match.getMatchId(),
            mTurnData.persist(), myParticipantId).setResultCallback(
            new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                @Override
                public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
                    processResult(result);
                }
            });
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:22,代码来源:SkeletonActivity.java

示例4: processResult

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
private void processResult(TurnBasedMultiplayer.InitiateMatchResult result) {
    TurnBasedMatch match = result.getMatch();
    dismissSpinner();

    if (!checkStatusCode(match, result.getStatus().getStatusCode())) {
        return;
    }

    if (match.getData() != null) {
        // This is a game that has already started, so I'll just start
        updateMatch(match);
        return;
    }

    startMatch(match);
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:17,代码来源:SkeletonActivity.java

示例5: ay

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
ay(DataHolder arg2)
{
  super(localc, localDataHolder);
  TurnBasedMatchBuffer localTurnBasedMatchBuffer = new TurnBasedMatchBuffer(localDataHolder);
  try
  {
    if (localTurnBasedMatchBuffer.getCount() > 0)
      this.un = ((TurnBasedMatch)((TurnBasedMatch)localTurnBasedMatchBuffer.get(0)).freeze());
    else
      this.un = null;
    return;
  }
  finally
  {
    localTurnBasedMatchBuffer.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:18,代码来源:fl.java

示例6: onConnected

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public final void onConnected(Bundle paramBundle)
{
  if (paramBundle != null)
  {
    Invitation localInvitation = (Invitation)paramBundle.getParcelable("invitation");
    if ((localInvitation != null) && (localInvitation.getInvitationId() != null))
    {
      this.ʽ = localInvitation;
      this.ʽ.getInvitationId();
    }
    this.゙ = ((TurnBasedMatch)paramBundle.getParcelable("turn_based_match"));
  }
  this.ʻ = null;
  this.ᐝ = true;
  this.ـ = false;
  this.ˊ = false;
  if (this.ͺ != null)
  {
    this.ͺ.onSignInSucceeded();
    return;
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:23,代码来源:Ô¨ª.java

示例7: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
/**
 * Starts a new match by loading the initial game state
 * @param match
 * @param gameID
 * @param gameVersion
 */
public void startMatch(TurnBasedMatch match, String gameID, String gameVersion) {
	mMatch = match;

	mTurnData = new TurnData();
	mTurnData.game = gameID;
	mTurnData.version = gameVersion;
	mTurnData.turnCounter = 1;

	initGameViewManager();
	mTurnData.state = mGame.getCurrentLevel().getUniverse().getState();

	String myParticipantId = mMatch.getParticipantId(mContext
			.getGamesClient().getCurrentPlayerId());

	// Taking this turn will cause turnBasedMatchUpdated
	mContext.getGamesClient().takeTurn(mContext, match.getMatchId(),
			mTurnData.persist(), myParticipantId);
}
 
开发者ID:elyas-bhy,项目名称:pygmy,代码行数:25,代码来源:GameHelper.java

示例8: onTurnBasedMatchReceived

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
@Override
public void onTurnBasedMatchReceived(TurnBasedMatch match) {
    int status = match.getStatus();
    int turnStatus = match.getTurnStatus();
    if (status != TurnBasedMatch.MATCH_STATUS_CANCELED &&
            status != TurnBasedMatch.MATCH_STATUS_EXPIRED &&
            status != TurnBasedMatch.MATCH_STATUS_AUTO_MATCHING &&
            status != TurnBasedMatch.MATCH_STATUS_COMPLETE) {
        if (turnStatus == TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN) {
            directUserToPlayGamesGUI("Received Match Update. It's your turn!");
        } else if (turnStatus == TurnBasedMatch.MATCH_TURN_STATUS_THEIR_TURN) {
            Toast.makeText(this, "Next Player's turn. We'll notify you when it's your turn again.", Toast.LENGTH_LONG).show();
        } else if (turnStatus == TurnBasedMatch.MATCH_TURN_STATUS_INVITED) {
            Toast.makeText(this, "Player invitations have been sent", Toast.LENGTH_LONG).show();
        }
    } else if (status == TurnBasedMatch.MATCH_STATUS_COMPLETE) {
        directUserToPlayGamesGUI("You have a game that just finished. Click 'View' to see the results");
    }

}
 
开发者ID:dustin-graham,项目名称:MorseWithPals,代码行数:21,代码来源:MainActivity.java

示例9: onQuickMatchClicked

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void onQuickMatchClicked(View view) {

    Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, 0);

    TurnBasedMatchConfig turnBasedMatchConfig = TurnBasedMatchConfig.builder()
        .setAutoMatchCriteria(autoMatchCriteria).build();

    showSpinner();

    // Start the match
    mTurnBasedMultiplayerClient.createMatch(turnBasedMatchConfig)
        .addOnSuccessListener(new OnSuccessListener<TurnBasedMatch>() {
          @Override
          public void onSuccess(TurnBasedMatch turnBasedMatch) {
            onInitiateMatch(turnBasedMatch);
          }
        })
        .addOnFailureListener(createFailureListener("There was a problem creating a match!"));
  }
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:20,代码来源:SkeletonActivity.java

示例10: onDoneClicked

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void onDoneClicked(View view) {
  showSpinner();

  String nextParticipantId = getNextParticipantId();
  // Create the next turn
  mTurnData.turnCounter += 1;
  mTurnData.data = mDataView.getText().toString();

  mTurnBasedMultiplayerClient.takeTurn(mMatch.getMatchId(),
      mTurnData.persist(), nextParticipantId)
      .addOnSuccessListener(new OnSuccessListener<TurnBasedMatch>() {
        @Override
        public void onSuccess(TurnBasedMatch turnBasedMatch) {
          onUpdateMatch(turnBasedMatch);
        }
      })
      .addOnFailureListener(createFailureListener("There was a problem taking a turn!"));

  mTurnData = null;
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:21,代码来源:SkeletonActivity.java

示例11: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void startMatch(TurnBasedMatch match) {
  mTurnData = new SkeletonTurn();
  // Some basic turn data
  mTurnData.data = "First turn";

  mMatch = match;

  String myParticipantId = mMatch.getParticipantId(mPlayerId);

  showSpinner();

  mTurnBasedMultiplayerClient.takeTurn(match.getMatchId(),
      mTurnData.persist(), myParticipantId)
      .addOnSuccessListener(new OnSuccessListener<TurnBasedMatch>() {
        @Override
        public void onSuccess(TurnBasedMatch turnBasedMatch) {
          updateMatch(turnBasedMatch);
        }
      })
      .addOnFailureListener(createFailureListener("There was a problem taking a turn!"));
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:22,代码来源:SkeletonActivity.java

示例12: onUpdateMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
public void onUpdateMatch(TurnBasedMatch match) {
  dismissSpinner();

  if (match.canRematch()) {
    askForRematch();
  }

  isDoingTurn = (match.getTurnStatus() == TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN);

  if (isDoingTurn) {
    updateMatch(match);
    return;
  }

  setViewVisibility();
}
 
开发者ID:playgameservices,项目名称:android-basic-samples,代码行数:17,代码来源:SkeletonActivity.java

示例13: getGameData

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
private GameData getGameData(@NonNull TurnBasedMatch turnBasedMatch) {
  byte[] data = turnBasedMatch.getData();
  if (data == null) {
    // When a crash happens during game creation, the TurnBasedMatch contains a null game
    // that can't be recovered, and would prevent starting the app.
    return null;
  }

  handleMatchStatusComplete(turnBasedMatch);
  try {
    GameData gameData = GameData.parseFrom(data);
    gameData = handleBackwardCompatibility(turnBasedMatch, gameData);
    return gameData;
  } catch (InvalidProtocolBufferException exception) {
    throw new RuntimeException(exception);
  }
}
 
开发者ID:cauchymop,项目名称:goblob,代码行数:18,代码来源:AndroidGameRepository.java

示例14: getTurnBasedMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
/**
 * Returns the tbmp match received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's a
 *                                            match available.
 * @return The match, or null if none was received.
 */
public TurnBasedMatch getTurnBasedMatch() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getTurnBasedMatch() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mTurnBasedMatch;
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:17,代码来源:GameHelper.java

示例15: getTurnBasedMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入依赖的package包/类
/**
 * Returns the tbmp match received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @return The match, or null if none was received.
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's a
 * match available.
 */
public TurnBasedMatch getTurnBasedMatch() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getTurnBasedMatch() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mTurnBasedMatch;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:17,代码来源:GameHelper.java


注:本文中的com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。