- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Xamarin.Android 和 MonoGame 制作 Android 游戏。我正在使用 Google Play 的 TurnBasedMatch用于处理游戏的多人游戏方面的 API。
在比赛结束时,我想确定本地玩家(在设备上登录 Google Play 的玩家)是否赢得了比赛。基本上,我希望能够说“你赢了!”或“你输了!”适本地。
令人惊讶的是,我无法在 TurnBasedMatch 库中找到任何东西来确定我是否赢得了比赛。我确定我一定遗漏了一些明显的东西。有没有人找到确定这些信息的方法?
谢谢!!
最佳答案
你可以这样做:
String localPlayerId = Games.Players.getCurrentPlayerId( getApiClient());
Participant localParticipant = mMatch.getParticipant( mMatch.getParticipantId( localPlayerId));
ParticipantResult result = localParticipant.getResult();
if (result != null && result.getResult() == ParticipantResult.MATCH_RESULT_WIN) {
// Local player won, show greetings...
}
注意:要使其正常工作,您之前必须调用 finishMatch(..),参与者结果如下:
List<ParticipantResult> participantResults = new ArrayList<ParticipantResult>();
participantResults.add( new ParticipantResult( participantId1, ParticipantResult.MATCH_RESULT_WIN, 1));
participantResults.add( new ParticipantResult( participantId2, ParticipantResult.MATCH_RESULT_LOSS, 2));
Games.TurnBasedMultiplayer.finishMatch(
getApiClient(),
mMatch.getMatchId(),
gameData,
participantResults
);
关于android - 如何确定本地玩家是否赢得了 Google Play TurnBasedMatch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29459271/
在使用 iOS6 实现回合制游戏时,我偶然发现了一些奇怪的东西。 我创建了一堆匹配项,游戏图标上写着“29”。 但是当运行这个时: [GKTurnBasedMatch loadMatchesWithC
我正在使用 Xamarin.Android 和 MonoGame 制作 Android 游戏。我正在使用 Google Play 的 TurnBasedMatch用于处理游戏的多人游戏方面的 API。
我知道我可以使用 TurnBasedMatch.getParticipants() 获取所有参与者,并且我知道轮到玩家时我可以通过 TurnBasedMatch.getPendingParticipa
编辑: 此问题已于 2014 年 1 月 21 日得到修复。 我目前正在开发基于 Google Play 游戏服务中新的 TurnBasedMatch API 的回合制安卓游戏。 当 Android
我是一名优秀的程序员,十分优秀!