• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TurnBasedMultiplayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: onResult

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

}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:29,代码来源:MatchInitiatedCallback.java


示例17: 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 (mGoogleApiClient == null || !mGoogleApiClient.isConnected()) {
                Log.d(TAG, "Warning: accessing TurnBasedMatch when not connected");
            }

            updateMatch(mTurnBasedMatch);
            return;
        }
    }

    setViewVisibility();

    // 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(mGoogleApiClient, 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(mGoogleApiClient, this);
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:34,代码来源:SkeletonActivity.java


示例18: onCancelClicked

import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMultiplayer; //导入依赖的package包/类
public void onCancelClicked(View view) {
    showSpinner();
    Games.TurnBasedMultiplayer.cancelMatch(mGoogleApiClient, mMatch.getMatchId())
            .setResultCallback(new ResultCallback<TurnBasedMultiplayer.CancelMatchResult>() {
                @Override
                public void onResult(TurnBasedMultiplayer.CancelMatchResult result) {
                    processResult(result);
                }
            });
    isDoingTurn = false;
    setViewVisibility();
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:13,代码来源:SkeletonActivity.java


示例19: onLeaveClicked

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

    Games.TurnBasedMultiplayer.leaveMatchDuringTurn(mGoogleApiClient, mMatch.getMatchId(),
            nextParticipantId).setResultCallback(
                new ResultCallback<TurnBasedMultiplayer.LeaveMatchResult>() {
        @Override
        public void onResult(TurnBasedMultiplayer.LeaveMatchResult result) {
            processResult(result);
        }
    });
    setViewVisibility();
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:15,代码来源:SkeletonActivity.java


示例20: onFinishClicked

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

    isDoingTurn = false;
    setViewVisibility();
}
 
开发者ID:NahroTo,项目名称:Fruit-Destroyer,代码行数:14,代码来源:SkeletonActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICostFunction类代码示例发布时间:2022-05-22
下一篇:
Java NodeResourceMapProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap