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


Java TurnBasedMultiplayer类代码示例

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


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

示例1: quickMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void quickMatch() {
	Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
			1, 1, 0);

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

	

	// Start the match
	ResultCallback<TurnBasedMultiplayer.InitiateMatchResult> cb = new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
		@Override
		public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
			processResult(result);
		}
	};
	Games.TurnBasedMultiplayer.createMatch(gameHelper.getApiClient(), tbmc).setResultCallback(cb);
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:20,代码来源:AndroidLauncher.java

示例2: takeTurn

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void takeTurn(GameModel data) {
	String nextParticipantId = getNextParticipantId();
	// Create the next turn
       mTurnData = new GameModelWrapper(data);

	

	Games.TurnBasedMultiplayer.takeTurn(gameHelper.getApiClient(), mMatch.getMatchId(),
			mTurnData.convertToByteArray(), nextParticipantId).setResultCallback(
			new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
					processResult(result);
				}
			});

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

示例3: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的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

示例4: onQuickMatchClicked

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

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

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

        showSpinner();

        // Start the match
        ResultCallback<TurnBasedMultiplayer.InitiateMatchResult> cb = new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
            @Override
            public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
                processResult(result);
            }
        };
        Games.TurnBasedMultiplayer.createMatch(mGoogleApiClient, tbmc).setResultCallback(cb);
    }
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:20,代码来源:SkeletonActivity.java

示例5: onDoneClicked

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

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

    showSpinner();

    Games.TurnBasedMultiplayer.takeTurn(mGoogleApiClient, mMatch.getMatchId(),
            mTurnData.persist(), nextParticipantId).setResultCallback(
            new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
        @Override
        public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
            processResult(result);
        }
    });

    mTurnData = null;
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:22,代码来源:SkeletonActivity.java

示例6: startMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的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

示例7: processResult

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的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

示例8: G

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
public TurnBasedMultiplayer.LoadMatchesResult G(final Status paramStatus)
{
  return new TurnBasedMultiplayer.LoadMatchesResult()
  {
    public LoadMatchesResponse getMatches()
    {
      return new LoadMatchesResponse(new Bundle());
    }

    public Status getStatus()
    {
      return paramStatus;
    }

    public void release()
    {
    }
  };
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:gb.java

示例9: publishRemoteGameState

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public boolean publishRemoteGameState(GameData gameData) {
  if (googleApiClient.isConnected()) {
    Log.d(TAG, "publishRemoteGameState: " + gameData);
    String turnParticipantId = gameDatas.getCurrentPlayer(gameData).getId();
    byte[] gameDataBytes = gameData.toByteArray();
    Log.d(TAG, "takeTurn " + turnParticipantId);
    TurnBasedMultiplayer.takeTurn(googleApiClient, gameData.getMatchId(), gameDataBytes, turnParticipantId);
    if (gameData.getPhase() == Phase.FINISHED) {
      TurnBasedMultiplayer.finishMatch(googleApiClient, gameData.getMatchId());
      fireGameSelected(gameData);
    }
    return true;
  } else {
    gameCache.putUnpublished(gameData.getMatchId(), IGNORED_VALUE);
    return false;
  }
}
 
开发者ID:cauchymop,项目名称:goblob,代码行数:19,代码来源:AndroidGameRepository.java

示例10: checkGames

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void checkGames() {
	if(isSignedIn()) {
		Intent intent = Games.TurnBasedMultiplayer.getInboxIntent(gameHelper.getApiClient());
		startActivityForResult(intent, RC_LOOK_AT_MATCHES);
	}
	else
		signIn();
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:10,代码来源:AndroidLauncher.java

示例11: takeLastTurn

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void takeLastTurn(GameModel data) {
	
	mTurnData = new GameModelWrapper(data);

	Games.TurnBasedMultiplayer.finishMatch(gameHelper.getApiClient(), mMatch.getMatchId(), mTurnData.convertToByteArray())
			.setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
					processResult(result);
				}
			});

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

示例12: finishMatch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void finishMatch() {
	Games.TurnBasedMultiplayer.finishMatch(gameHelper.getApiClient(), mMatch.getMatchId())
			.setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
					processResult(result);
				}
			});

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

示例13: rematch

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void rematch() {
	Games.TurnBasedMultiplayer.rematch(gameHelper.getApiClient(), mMatch.getMatchId()).setResultCallback(
			new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
					processResult(result);
				}
			});
	mMatch = null;
	isDoingTurn = false;
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:13,代码来源:AndroidLauncher.java

示例14: processResult

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
private void processResult(TurnBasedMultiplayer.CancelMatchResult result) {
	if (!checkStatusCode(null, result.getStatus().getStatusCode())) {
		return;
	}

	isDoingTurn = false;

	showWarning("Match",
			"This match is canceled.  All other players will have their game ended.");
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:11,代码来源:AndroidLauncher.java

示例15: onConnected

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
	Log.d(TAG, "onConnected(): Connection successful");

	// Retrieve the TurnBasedMatch from the connectionHint
	if (connectionHint != null) {
		mTurnBasedMatch = connectionHint.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);

		if (mTurnBasedMatch != null) {
			if (gameHelper.getApiClient() == null || !gameHelper.getApiClient().isConnected()) {
				Log.d(TAG, "Warning: accessing TurnBasedMatch when not connected");
			}

			updateMatch(mTurnBasedMatch);
			return;
		}
	}


	// As a demonstration, we are registering this activity as a handler for
	// invitation and match events.

	// This is *NOT* required; if you do not register a handler for
	// invitation events, you will get standard notifications instead.
	// Standard notifications may be preferable behavior in many cases.
	Games.Invitations.registerInvitationListener(gameHelper.getApiClient(), this);

	// Likewise, we are registering the optional MatchUpdateListener, which
	// will replace notifications you would get otherwise. You do *NOT* have
	// to register a MatchUpdateListener.
	Games.TurnBasedMultiplayer.registerMatchUpdateListener(gameHelper.getApiClient(), this);
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:33,代码来源:AndroidLauncher.java


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