/// <summary> /// Initializes the wrapper. /// </summary> /// <param name="nsObj">The NSObject.</param> /// <param name="id">Identifier.</param> protected override void _InitWrapper(NSObject nsObj, string id = null) { base._InitWrapper(nsObj, id); // get wrappers for participants _participants = TurnBasedParticipant.ToParticipants(gkTurnBasedMatch.participants); }
/// <summary> /// Updates the data stored on Game Center for the current match and advances the turn. /// Raises AdvanceTurnCompleted and AdvanceTurnFailed events for success and error completion. /// On iOS 5.0, it only takes one next participant, and ignores the timeout. /// </summary> /// <param name="matchData">A serialized blob of data reflecting the game-specific state for the match.</param> /// <param name="aMessage">A message to display reflecting the state of the match.</param> /// <param name="nextParticipants">An array of TurnBasedParticipant objects reflecting the order in which the players should act next. /// Each object in the array must be one of the objects stored in the match’s participants property. /// If null or not specified, it would use the next player in the order of the participants property.</param> /// <param name="timeout">The length of time the next player has to complete their turn; in seconds.</param> public void AdvanceTurn(byte[] matchData, string aMessage = null, TurnBasedParticipant[] nextParticipants = null, double timeout = 0) { if (aMessage != null) { gkTurnBasedMatch.message = aMessage; } if (nextParticipants == null) { nextParticipants = _GetNextActiveParticipants(); } //hack: apple server doesn't work if it takes an array, so popping all except 1 now if (nextParticipants.Length > 1) { nextParticipants = new TurnBasedParticipant[] { nextParticipants[0] } } ; if (gkTurnBasedMatch.RespondsToSelector("endTurnWithNextParticipants:turnTimeout:matchData:completionHandler:")) { gkTurnBasedMatch.EndTurn( TurnBasedParticipant.ToGKParticipants(nextParticipants), timeout, NSData.FromByteArray(matchData), _CreateCompleteFunction(_advanceTurnCompletedHandlers, _advanceTurnFailedHandlers)); } else { gkTurnBasedMatch.EndTurn( TurnBasedParticipant.ToGKParticipants(nextParticipants)[0], NSData.FromByteArray(matchData), _CreateCompleteFunction(_advanceTurnCompletedHandlers, _advanceTurnFailedHandlers)); } }
/// <summary> /// Sends a reminder to participants. /// Available in iOS 7.0 and later. /// Raises SendReminderCompleted and SendReminderFailed events. /// </summary> /// <param name="participants">Participants to receive the reminder.</param> /// <param name="messageKey">The location of the alert message string in the Localizable.strings file for the current localization.</param> /// <param name="messageArgs">An array of strings to be substituted using the format string.</param> public void SendReminder(TurnBasedParticipant[] participants, string messageKey, string[] messageArgs) { gkTurnBasedMatch.SendReminderToParticipants( TurnBasedParticipant.ToGKParticipants(participants), messageKey, messageArgs, _CreateCompleteFunction(_sendReminderCompletedHandlers, _sendReminderFailedHandlers)); }
/// <summary> /// Sends an exchange request to one or more participants. /// Raises ExchangeSent event after completion. Check the error property of the event for errors. /// Available in iOS 7.0 and later. /// </summary> /// <param name="participants">The participants to receive the exchange.</param> /// <param name="data">Data.</param> /// <param name="messageKey">The location of the alert message string in the Localizable.strings file for the current localization.</param> /// <param name="messageArgs">An array of strings to be substituted using the format string.</param> /// <param name="timeout">The length of time the next player has to complete their turn.</param> public void SendExchange(TurnBasedParticipant[] participants, byte[] data, string messageKey, string[] messageArgs, double timeout) { gkTurnBasedMatch.SendExchangeToParticipants( TurnBasedParticipant.ToGKParticipants(participants), NSData.FromByteArray(data), messageKey, messageArgs, timeout, _SendExchangeCompleteHander); }
/// <summary> /// Resigns the current player from the match without ending the match. /// Raises QuitMatchCompleted and QuitMatchFailed events for success and error completion. /// On iOS 5.0, it only takes one next participant, and ignores the timeout. /// </summary> /// <param name="matchOutcome">The end outcome of the current player in the match.</param> /// <param name="matchData">A serialized string of data reflecting the game-specific state for the match.</param> /// <param name="aMessage">A message to display reflecting the state of the match.</param> /// <param name="nextParticipants">An array of TurnBasedParticipant objects reflecting the order in which the players should act next. /// Each object in the array must be one of the objects stored in the match’s participants property. /// If null or not specified, it would use the next player in the order of the participants property.</param> /// <param name="timeout">The length of time the next player has to complete their turn; in seconds.</param> public void QuitDuringTurn(GKTurnBasedMatchOutcome matchOutcome, string matchData, string aMessage = null, TurnBasedParticipant[] nextParticipants = null, double timeout = 0) { QuitDuringTurn(matchOutcome, matchData.ToStraightBytes(), aMessage, nextParticipants, timeout); }
internal static GKTurnBasedParticipant[] ToGKParticipants(TurnBasedParticipant[] participants) { return participants.Select(x => x.gkTurnBasedParticipant).ToArray(); }
/// <summary> /// Resigns the current player from the match without ending the match. /// Raises QuitMatchCompleted and QuitMatchFailed events for success and error completion. /// On iOS 5.0, it only takes one next participant, and ignores the timeout. /// </summary> /// <param name="matchOutcome">The end outcome of the current player in the match.</param> /// <param name="matchData">A serialized blob of data reflecting the game-specific state for the match.</param> /// <param name="aMessage">A message to display reflecting the state of the match.</param> /// <param name="nextParticipants">An array of TurnBasedParticipant objects reflecting the order in which the players should act next. /// Each object in the array must be one of the objects stored in the match’s participants property. /// If null or not specified, it would use the next player in the order of the participants property.</param> /// <param name="timeout">The length of time the next player has to complete their turn; in seconds.</param> public void QuitDuringTurn(GKTurnBasedMatchOutcome matchOutcome, byte[] matchData, string aMessage = null, TurnBasedParticipant[] nextParticipants = null, double timeout = 0) { if (aMessage != null) gkTurnBasedMatch.message = aMessage; if (nextParticipants == null) nextParticipants = _GetNextActiveParticipants(); //hack: apple server doesn't work if it takes an array, so popping all except 1 now if (nextParticipants.Length > 1) nextParticipants = new TurnBasedParticipant[] { nextParticipants[0] }; if (gkTurnBasedMatch.RespondsToSelector("participantQuitInTurnWithOutcome:nextParticipants:turnTimeout:matchData:completionHandler:")) { gkTurnBasedMatch.ParticipantQuitInTurn( matchOutcome, TurnBasedParticipant.ToGKParticipants(nextParticipants), timeout, NSData.FromByteArray(matchData), _CreateCompleteFunction(_quitMatchCompletedHandlers, _quitMatchFailedHandlers)); } else { gkTurnBasedMatch.ParticipantQuitInTurn( matchOutcome, TurnBasedParticipant.ToGKParticipants(nextParticipants)[0], NSData.FromByteArray(matchData), _CreateCompleteFunction(_quitMatchCompletedHandlers, _quitMatchFailedHandlers)); } }
/// <summary> /// Updates the data stored on Game Center for the current match and advances the turn. /// Raises AdvanceTurnCompleted and AdvanceTurnFailed events for success and error completion. /// On iOS 5.0, it only takes one next participant, and ignores the timeout. /// </summary> /// <param name="matchData">A serialized string of data reflecting the game-specific state for the match.</param> /// <param name="aMessage">A message to display reflecting the state of the match.</param> /// <param name="nextParticipants">An array of TurnBasedParticipant objects reflecting the order in which the players should act next. /// Each object in the array must be one of the objects stored in the match’s participants property. /// If null or not specified, it would use the next player in the order of the participants property.</param> /// <param name="timeout">The length of time the next player has to complete their turn; in seconds.</param> public void AdvanceTurn(string matchData, string aMessage = null, TurnBasedParticipant[] nextParticipants = null, double timeout = 0) { AdvanceTurn(matchData.ToStraightBytes(), aMessage, nextParticipants, timeout); }
/// <summary> /// Sends an exchange request to one or more participants. /// Raises ExchangeSent event after completion. Check the error property of the event for errors. /// Available in iOS 7.0 and later. /// </summary> /// <param name="participants">The participants to receive the exchange.</param> /// <param name="data">Data.</param> /// <param name="messageKey">The location of the alert message string in the Localizable.strings file for the current localization.</param> /// <param name="messageArgs">An array of strings to be substituted using the format string.</param> /// <param name="timeout">The length of time the next player has to complete their turn.</param> public void SendExchange(TurnBasedParticipant[] participants, string data, string messageKey, string[] messageArgs, double timeout) { SendExchange( participants, data.ToStraightBytes(), messageKey, messageArgs, timeout); }