本文整理汇总了Java中com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch.getData方法的典型用法代码示例。如果您正苦于以下问题:Java TurnBasedMatch.getData方法的具体用法?Java TurnBasedMatch.getData怎么用?Java TurnBasedMatch.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch
的用法示例。
在下文中一共展示了TurnBasedMatch.getData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: processResult
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
private void processResult(TurnBasedMultiplayer.InitiateMatchResult result) {
TurnBasedMatch match = result.getMatch();
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);
}
示例5: onResult
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
@Override
public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
// Check if the status code is not success.
Status status = result.getStatus();
if (!status.isSuccess()) {
Log.d("##MACHINITIATEDCALLBACK","errore!");
return;
}
TurnBasedMatch match = result.getMatch();
// If this player is not the first player in this match, continue.
if (match.getData() != null) {
Log.d("##MACHINITIATEDCALLBACK","WAITING FOR MY TURN");
return;
}
// Otherwise, this is the first player. Initialize the game state.
Log.d("##MACHINITIATEDCALLBACK","GAME STARTED");
//initGame(match);
// Let the player take the first turn
Log.d("##MACHINITIATEDCALLBACK","showTurnUi");
//showTurnUI(match);
}
示例6: startNewGame
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
private void startNewGame(TurnBasedMultiplayer.InitiateMatchResult result) {
TurnBasedMatch match = result.getMatch();
int status = result.getStatus().getStatusCode();
if (status != GamesStatusCodes.STATUS_OK && status != GamesStatusCodes.STATUS_NETWORK_ERROR_OPERATION_DEFERRED) {
return;
}
// Initial setup
if (match.getData() == null) {
MultiplayerData initialData = initDataAndUI(match);
takeTurn(match.getMatchId(), initialData.toBytes(), initialData.getPlayer2ID());
}
}
示例7: updateGame
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
private void updateGame(TurnBasedMatch match) {
int status = match.getStatus();
int turnStatus = match.getTurnStatus();
switch (status) {
case TurnBasedMatch.MATCH_STATUS_AUTO_MATCHING:
Toast.makeText(mActivity, mActivity.getString(R.string.multiplayer_match_automatching), Toast.LENGTH_SHORT).show();
return;
case TurnBasedMatch.MATCH_STATUS_EXPIRED:
Toast.makeText(mActivity, mActivity.getString(R.string.multiplayer_match_expired), Toast.LENGTH_SHORT).show();
return;
case TurnBasedMatch.MATCH_STATUS_CANCELED:
Toast.makeText(mActivity, mActivity.getString(R.string.multiplayer_match_canceled), Toast.LENGTH_SHORT).show();
return;
case TurnBasedMatch.MATCH_STATUS_COMPLETE:
if (turnStatus == TurnBasedMatch.MATCH_TURN_STATUS_COMPLETE) {
Toast.makeText(mActivity, mActivity.getString(R.string.multiplayer_match_complete), Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new GameEndedEvent(false));
}
break;
default:
}
if (turnStatus == TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN) {
playTurn(match);
} else {
mData = new MultiplayerData(match.getData());
mPlayer1Name.setText(mData.getPlayer1Name());
mPlayer2Name.setText(mData.getPlayer2Name());
changeRoundIndicators(mData);
mLayoutInput.setVisibility(View.GONE);
}
}
示例8: onTurnBasedMatchInitiated
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
public void onTurnBasedMatchInitiated(int statusCode, TurnBasedMatch match) {
if (!checkStatusCode(match, statusCode)) {
return;
}
if (match.getData() != null) {
// This is a game that has already started, so just start it
updateMatch(match);
return;
}
mContext.startMatch(match);
}
示例9: onTurnBasedMatchInitiated
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
@Override
public void onTurnBasedMatchInitiated(int statusCode, TurnBasedMatch match) {
//start the game activity and pass the match in
if (!checkStatusCode(match, statusCode)) {
return;
}
if (match.getData() != null) {
// This is a game that has already started, so I'll just start
updateMatch(match);
return;
}
launchRound(match);
}
示例10: onInitiateMatch
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch; //导入方法依赖的package包/类
private void onInitiateMatch(TurnBasedMatch match) {
dismissSpinner();
if (match.getData() != null) {
// This is a game that has already started, so I'll just start
updateMatch(match);
return;
}
startMatch(match);
}