在 finishMatch 上结束多人游戏

End a multiplayer game on finishMatch

我正在 Android 使用 Google Play Game Services 开发一款回合制多人游戏。

我已经在用户点击完成时成功结束了游戏Button:

    Games.TurnBasedMultiplayer.finishMatch(mGoogleApiClient, mMatch.getMatchId(), mMatch.getData(), creatorResult, opponentResult)
            .setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
                @Override
                public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
                    processResult(result);
                }
            });

当前玩家的游戏在 "Completed Games" 部分更新。

然而对手的游戏被列为"My Turn"

来自 Developing a Turn Based Multiplayer Game in Android 页面:

"Play Game services sends a notification to all other match participants to inform them that the match is over. These participants see this match under Your Turn category in their respective match list UIs. At this point, your game can call finishMatch() for these participants to save their final game data. Invoking this method also moves the match to the Completed Matches category in the participant’s match list UI."

如何为其他玩家调用 finishMatch

--是否通过mGoogleApiClient

--或者有没有办法让对手的匹配状态=MATCH_STATUS_COMPLETE

有人可以帮忙吗?

您应该在每个其他玩家设备上进行以下调用:

Games.TurnBasedMultiplayer.finishMatch( mGoogleApiClient, mMatch.getMatchId());

这将导致每个玩家设备上的状态发生以下变化:

  • 匹配状态将从 MATCH_STATUS_ACTIVE 更改为 MATCH_STATUS_COMPLETE
  • 比赛回合状态将从 MATCH_TURN_STATUS_MY_TURN 到 MATCH_TURN_STATUS_COMPLETE.
  • 玩家的参赛状态将从STATUS_JOINED变为 STATUS_FINISHED.

请注意,玩家的参与者状态可能会在其他玩家设备上保持 STATUS_JOINED(至少我在实施中看到的是这样)。