示例#1
0
        /// <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);
        }
示例#2
0
        /// <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));
            }
        }
示例#3
0
 /// <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));
 }
示例#4
0
 /// <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);
 }
示例#5
0
 /// <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);
 }
示例#6
0
 internal static GKTurnBasedParticipant[] ToGKParticipants(TurnBasedParticipant[] participants)
 {
     return participants.Select(x => x.gkTurnBasedParticipant).ToArray();
 }
示例#7
0
        /// <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));
            }
        }
示例#8
0
 /// <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);
 }
示例#9
0
 /// <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));
 }
示例#10
0
 /// <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);
 }
示例#11
0
 /// <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);
 }