本文整理汇总了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);
}
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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);
}
示例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");
}
}
示例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!"));
}
示例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;
}
示例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!"));
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}