private static void _EndAndRemoveMatch(GKTurnBasedMatch match) { try { (match.participants[0] as GKTurnBasedParticipant).matchOutcome = GKTurnBasedMatchOutcome.Won; for (var i = match.participants.Length - 1; i > 0; i--) { (match.participants[i] as GKTurnBasedParticipant).matchOutcome = GKTurnBasedMatchOutcome.Lost; } match.EndMatchInTurn((match.matchData != null) ? match.matchData : new NSData(), delegate(NSError error) { if (error != null) { Debug.Log("end match error: " + error.LocalizedDescription()); } match.Remove(delegate(NSError error2) { if (error2 != null) { Debug.Log("remove match error: " + error2.LocalizedDescription()); } }); }); } catch (Exception e) { Debug.Log("remove match error: " + e + ": " + e.StackTrace); } }
public override void PlayerQuitForMatch(GKTurnBasedMatchmakerViewController viewController, GKTurnBasedMatch match) { Logger.I("MatchMakerDelegate.PlayerQuitForMatch"); // Mark current player as quiter foreach (GKTurnBasedParticipant participant in match.Participants) { if (participant.PlayerID == GKLocalPlayer.LocalPlayer.PlayerID) { participant.MatchOutcome = GKTurnBasedMatchOutcome.Quit; } else { // Win? participant.MatchOutcome = GKTurnBasedMatchOutcome.Won; } } //viewController.DismissViewController (true, null); // Delete the match match.Remove(new GKNotificationHandler((error) => { Logger.E("MatchMakerDelegate.PlayerQuitForMatch: " + error.DebugDescription); })); if (PlayerQuitCallback != null) { PlayerQuitCallback(); } }
public override void FoundMatch(GKTurnBasedMatchmakerViewController viewController, GKTurnBasedMatch match) { Logger.I("MatchMakerDelegate.FoundMatch"); viewController.DismissViewController(true, null); PuzzleData puzzleData = new PuzzleData(); puzzleData.Match = match; puzzleData.MatchId = match.MatchID; bool matchError = false; if (match.MatchData.Length > 0) { // Match has data // var tp = GameCenterHelper.GetPuzzleFromMatch (match); // TODO ? } else { // No data: new match // Set up outcomes // -> Player who sent the picture set a time first match.Participants [0].MatchOutcome = GKTurnBasedMatchOutcome.First; match.Participants [1].MatchOutcome = GKTurnBasedMatchOutcome.Second; } if (matchError == false) { match.Remove(new GKNotificationHandler((e) => {})); if (MatchFoundCallback != null) { MatchFoundCallback(puzzleData); } } else { if (ErrorCallback != null) { ErrorCallback(); } } }
public override void PlayerQuitForMatch(GKTurnBasedMatchmakerViewController viewController, GKTurnBasedMatch match) { Logger.I ("MatchMakerDelegate.PlayerQuitForMatch"); // Mark current player as quiter foreach (GKTurnBasedParticipant participant in match.Participants) { if (participant.PlayerID == GKLocalPlayer.LocalPlayer.PlayerID) { participant.MatchOutcome = GKTurnBasedMatchOutcome.Quit; } else { // Win? participant.MatchOutcome = GKTurnBasedMatchOutcome.Won; } } //viewController.DismissViewController (true, null); // Delete the match match.Remove (new GKNotificationHandler ((error) => { Logger.E ("MatchMakerDelegate.PlayerQuitForMatch: " + error.DebugDescription); })); if (PlayerQuitCallback != null) PlayerQuitCallback (); }
public override void FoundMatch(GKTurnBasedMatchmakerViewController viewController, GKTurnBasedMatch match) { Logger.I ("MatchMakerDelegate.FoundMatch"); viewController.DismissViewController (true, null); PuzzleData puzzleData = new PuzzleData (); puzzleData.Match = match; puzzleData.MatchId = match.MatchID; bool matchError = false; if (match.MatchData.Length > 0) { // Match has data // var tp = GameCenterHelper.GetPuzzleFromMatch (match); // TODO ? } else { // No data: new match // Set up outcomes // -> Player who sent the picture set a time first match.Participants [0].MatchOutcome = GKTurnBasedMatchOutcome.First; match.Participants [1].MatchOutcome = GKTurnBasedMatchOutcome.Second; } if (matchError == false) { match.Remove (new GKNotificationHandler ((e) => {})); if (MatchFoundCallback != null) { MatchFoundCallback (puzzleData); } } else { if (ErrorCallback != null) { ErrorCallback (); } } }
private static void _EndAndRemoveMatch(GKTurnBasedMatch match) { try { (match.participants[0] as GKTurnBasedParticipant).matchOutcome = GKTurnBasedMatchOutcome.Won; for (var i=match.participants.Length-1; i>0; i--) (match.participants[i] as GKTurnBasedParticipant).matchOutcome = GKTurnBasedMatchOutcome.Lost; match.EndMatchInTurn((match.matchData != null) ? match.matchData : new NSData(), delegate(NSError error) { if (error != null) { Debug.Log("end match error: " + error.LocalizedDescription()); } match.Remove(delegate(NSError error2) { if (error2 != null) Debug.Log("remove match error: " + error2.LocalizedDescription()); }); }); } catch (Exception e) { Debug.Log("remove match error: " + e + ": " + e.StackTrace); } }
public static void KillMatch(GKTurnBasedMatch match) { Logger.W ("Removing match..." + match.MatchID + " " + match.Status); match.Participants [0].MatchOutcome = GKTurnBasedMatchOutcome.Won; match.Participants [1].MatchOutcome = GKTurnBasedMatchOutcome.Lost; NSData d; if (match.MatchData == null) { d = NSData.FromString ("Wabon"); } else { d = match.MatchData; } match.EndMatchInTurn (d, (e1) => { if (e1 != null) { Logger.E ("GameCenterHelper.KillMatch - EndMatchInTurn", e1); } match.Remove (new GKNotificationHandler ((e2) => { if (e2 != null) { Logger.E ("GameCenterHelper.KillMatch - Remove", e2); } })); }); }