public void ShowGameOverUI(MatchOutcome.ParticipantResult result, bool showRematchButton) { leaveMatchButton.gameObject.SetActive(false); IsInPlayingMode = false; resultRootObject.SetActive(true); resultText.text = GetResultText(result); rematchButton.gameObject.SetActive(showRematchButton); var tempModel = currentModel; currentModel = null; selfInfos.Update(tempModel.Match.Self.Player.image, GetSpriteForTile(tempModel.LocalPlayerMark.ToTileState()), GetColorForTile(tempModel.LocalPlayerMark.ToTileState()), tempModel.Match.Self.DisplayName, false); opponentInfos.Update((tempModel.Opponent != null && tempModel.Opponent.Player != null) ? tempModel.Opponent.Player.image : defaulAvatar, GetSpriteForTile(tempModel.OpponentMark.ToTileState()), GetColorForTile(tempModel.OpponentMark.ToTileState()), tempModel.Opponent != null ? tempModel.Opponent.DisplayName : "Unmatched player", false, tempModel.Opponent != null && tempModel.Opponent.Player == null); }
public void SetParticipantResult(string participantId, MatchOutcome.ParticipantResult result, int placement) { if (!this.mParticipantIds.Contains(participantId)) { this.mParticipantIds.Add(participantId); } this.mPlacements[participantId] = placement; this.mResults[participantId] = result; }
public void EndGame(MatchOutcome.ParticipantResult result) { ShowGameOverUI(result, true); foreach (var array in board) { foreach (var button in array) { button.interactable = false; } } }
private string GetResultText(MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.Won: return(wonText); case MatchOutcome.ParticipantResult.Lost: return(loseText); case MatchOutcome.ParticipantResult.Tied: return(tiedText); case MatchOutcome.ParticipantResult.CustomPlacement: case MatchOutcome.ParticipantResult.None: default: return("Unknown"); } }
private void EndGame(MatchOutcome.ParticipantResult localPlayerResult, MatchOutcome.ParticipantResult opponentResult, int x, int y, Action <TicTacToeGameModel.Mark> successCallback) { if (model == null) { return; } MatchOutcome outcome = new MatchOutcome(); outcome.SetParticipantResult(model.Match.SelfParticipantId, localPlayerResult); outcome.SetParticipantResult(model.Opponent.ParticipantId, opponentResult); model.TransferDatas.IsGameOver = true; model.TransferDatas.FinalResult = outcome; model.TransferDatas.CurrentTurn = GetOppositeMark(model.TransferDatas.CurrentTurn); model.TransferDatas.MoveCount++; CanMove = false; view.StartProgressUI("Ending game"); GameServices.TurnBased.Finish(model.Match, model.TransferDatas.ToByteArray(), outcome, success => { view.StopProgressUI("Ending game: " + GetResultMessage(success)); if (!success) { CanMove = true; model.TransferDatas.CurrentTurn = GetOppositeMark(model.TransferDatas.CurrentTurn); model.TransferDatas.IsGameOver = false; model.TransferDatas.FinalResult = null; model.TransferDatas.MoveCount--; model.TransferDatas.Board[x][y] = TicTacToeGameModel.TileState.Blank; } else { view.EndGame(localPlayerResult); if (successCallback != null) { successCallback(GetOppositeMark(model.TransferDatas.CurrentTurn)); } } }); }
/// <summary> /// Convert from <see cref="MatchOutcome.ParticipantResult"/> /// to <see cref="GooglePlayGames.BasicApi.Multiplayer.MatchOutcome.ParticipantResult"/>. /// </summary> /// <param name="result"></param> /// <returns></returns> public static GPGS_MatchOutcome.ParticipantResult ToGPGSParticipantResult(this MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.Won: return(GPGS_MatchOutcome.ParticipantResult.Win); case MatchOutcome.ParticipantResult.Lost: return(GPGS_MatchOutcome.ParticipantResult.Loss); case MatchOutcome.ParticipantResult.Tied: return(GPGS_MatchOutcome.ParticipantResult.Tie); case MatchOutcome.ParticipantResult.None: case MatchOutcome.ParticipantResult.CustomPlacement: // CustomPlacement is for iOS only. So this won't happen anw. default: return(GPGS_MatchOutcome.ParticipantResult.None); } }
public static int GetAndroidParticipantResult(MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.Win: return(JavaConsts.MATCH_RESULT_WIN); case MatchOutcome.ParticipantResult.Loss: return(JavaConsts.MATCH_RESULT_LOSS); case MatchOutcome.ParticipantResult.Tie: return(JavaConsts.MATCH_RESULT_TIE); case MatchOutcome.ParticipantResult.None: return(JavaConsts.MATCH_RESULT_NONE); default: return(JavaConsts.MATCH_RESULT_UNINITIALIZED); } }
public static int GetAndroidParticipantResult(MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.None: return(3); case MatchOutcome.ParticipantResult.Win: return(0); case MatchOutcome.ParticipantResult.Loss: return(1); case MatchOutcome.ParticipantResult.Tie: return(2); default: return(-1); } }
private static Types.MatchResult ResultToMatchResult(MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.Loss: return(Types.MatchResult.LOSS); case MatchOutcome.ParticipantResult.None: return(Types.MatchResult.NONE); case MatchOutcome.ParticipantResult.Tie: return(Types.MatchResult.TIE); case MatchOutcome.ParticipantResult.Win: return(Types.MatchResult.WIN); default: Logger.e("Received unknown ParticipantResult " + result); return(Types.MatchResult.NONE); } }
private static int convertParticipantResultToiOSInt(MatchOutcome.ParticipantResult result) { switch (result) { case MatchOutcome.ParticipantResult.Unset: return(-1); case MatchOutcome.ParticipantResult.None: return(3); case MatchOutcome.ParticipantResult.Win: return(0); case MatchOutcome.ParticipantResult.Loss: return(1); case MatchOutcome.ParticipantResult.Tie: return(2); } // Don't know what this is. Best to leave it as None for now. return(3); }
public void SetParticipantResult(string participantId, MatchOutcome.ParticipantResult result) { this.SetParticipantResult(participantId, result, -1); }
private string GetResultText(MatchOutcome.ParticipantResult result) { return(null); }
public void ShowGameOverUI(MatchOutcome.ParticipantResult result, bool showRematchButton) { }
public void EndGame(MatchOutcome.ParticipantResult result) { }
public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action <bool> callback) { callback = ToOnGameThread(callback); GetMatchAndroidJavaObject(match.MatchId, (status, foundMatch) => { if (!status) { callback(false); return; } using (var results = new AndroidJavaObject("java.util.ArrayList")) { Dictionary <string, AndroidJavaObject> idToResult = new Dictionary <string, AndroidJavaObject>(); using (var participantList = foundMatch.Call <AndroidJavaObject>("getParticipants")) { int size = participantList.Call <int>("size"); for (int i = 0; i < size; ++i) { try { using (var participantResult = participantList.Call <AndroidJavaObject>("get", i) .Call <AndroidJavaObject>("getResult")) { string id = participantResult.Call <string>("getParticipantId"); idToResult[id] = participantResult; results.Call <AndroidJavaObject>("add", participantResult); } } catch (Exception e) { // if getResult returns null. } } } foreach (string participantId in outcome.ParticipantIds) { MatchOutcome.ParticipantResult result = outcome.GetResultFor(participantId); uint placing = outcome.GetPlacementFor(participantId); if (idToResult.ContainsKey(participantId)) { var existingResult = idToResult[participantId].Get <int>("result"); uint existingPlacing = (uint)idToResult[participantId].Get <int>("placing"); if (result != (MatchOutcome.ParticipantResult)existingResult || placing != existingPlacing) { OurUtils.Logger.e(string.Format("Attempted to override existing results for " + "participant {0}: Placing {1}, Result {2}", participantId, existingPlacing, existingResult)); callback(false); return; } } else { using (var participantResult = new AndroidJavaObject( "com.google.android.gms.games.multiplayer.ParticipantResult", participantId, (int)result, (int)placing)) { results.Call <bool>("add", participantResult); } } } using (var task = mClient.Call <AndroidJavaObject>("finishMatch", match.MatchId, data, results)) { AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>( task, turnBasedMatch => callback(true)); AndroidTaskUtils.AddOnFailureListener(task, e => callback(false)); } } }); }
private void EndGame(MatchOutcome.ParticipantResult localPlayerResult, MatchOutcome.ParticipantResult opponentResult, int x, int y, Action <TicTacToeGameModel.Mark> successCallback) { }