Ejemplo n.º 1
0
 /// <summary>
 /// Enables the matchmaking process to find nearby players through Bluetooth or WiFi (same subnet only).
 /// </summary>
 /// <param name="reachableHandler">Reachable handler.</param>
 public void StartBrowsingForNearbyPlayers(Action <GKPlayer, bool> reachableHandler)
 {
     C.GKMatchmaker_startBrowsingForNearbyPlayers(
         SelfPtr(),
         PlayerBoolCallback,
         PInvokeCallbackUtil.ToIntPtr(reachableHandler));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Programmatically removes a match from Game Center.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void Remove(Action <NSError> completionHandler)
 {
     C.GKTurnBasedMatch_remove(
         SelfPtr(),
         InternalErrorOnlyCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 3
0
        internal static void InternalSaveGameData(iOSGKSavedGame savedGame, byte[] data, Action <iOSGKSavedGame, string> callback)
        {
            Util.NullArgumentTest(savedGame);
            Util.NullArgumentTest(data);
            Util.NullArgumentTest(callback);

            iOSSavedGameNative._SaveGameData(
                savedGame.ToPointer(),
                data,
                data.Length,
                InternalSaveGameDataCallback,
                PInvokeCallbackUtil.ToIntPtr <SaveGameDataResponse>(
                    response =>
            {
                string error = response.GetError();
                if (string.IsNullOrEmpty(error))
                {
                    callback(response.GetSavedGame(), error);
                }
                else
                {
                    callback(null, error);
                }
            },
                    SaveGameDataResponse.FromPointer
                    )
                );
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initiates a search for activity in all player groups.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void QueryActivity(Action <int, NSError> completionHandler)
 {
     C.GKMatchmaker_queryActivity(
         SelfPtr(),
         IntErrorCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new turn-based match with the same participants as an existing match.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void Rematch(Action <GKTurnBasedMatch, NSError> completionHandler)
 {
     C.GKTurnBasedMatch_rematch(
         SelfPtr(),
         InternalSingleMatchCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Loads a specific match.
 /// </summary>
 /// <param name="matchID">Match I.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public static void LoadMatchWithID(string matchID, Action <GKTurnBasedMatch, NSError> completionHandler)
 {
     C.GKTurnBasedMatch_loadMatchWithID(
         matchID,
         InternalSingleMatchCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Loads the game-specific data associated with a match, including all exchanges.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void LoadMatchData(Action <byte[], NSError> completionHandler)
 {
     C.GKTurnBasedMatch_loadMatchData(
         SelfPtr(),
         InternalLoadMatchDataCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns a Boolean value that indicates whether the enumeration of
        /// all contacts matching a contact fetch request executed successfully.
        /// </summary>
        /// <returns><c>true</c>, if contacts with fetch request was enumerated, <c>false</c> otherwise.</returns>
        /// <param name="fetchRequest">Fetch request.</param>
        /// <param name="error">Error.</param>
        /// <param name="block">Block.</param>
        public bool EnumerateContactsWithFetchRequest(CNContactFetchRequest fetchRequest, out NSError error, EnumerateContactsWithFetchRequestBlock block)
        {
            Util.NullArgumentTest(fetchRequest);
            Util.NullArgumentTest(block);

            IntPtr errorPtr = new IntPtr();
            bool   success  = C.CNContactStore_enumerateContactsWithFetchRequest(
                SelfPtr(),
                fetchRequest.ToPointer(),
                ref errorPtr,
                InternalEnumerateContactsBlock,
                PInvokeCallbackUtil.ToIntPtr((CNContact contact) =>
            {
                bool shouldStop;
                block(contact, out shouldStop);
                return(shouldStop);
            }));

            error = null;
            if (PInvokeUtil.IsNotNull(errorPtr))
            {
                error = new NSError(errorPtr);
                CFFunctions.CFRelease(errorPtr);     // balance out ref count of a pointer returned directly from native side.
            }

            return(success);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Returns an array of players the local player recently played with.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void LoadRecentPlayers(Action <GKPlayer[], NSError> completionHandler)
 {
     C.GKLocalPlayer_loadRecentPlayers(
         SelfPtr(),
         InternalLoadRecentPlayersCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Determines the best player in the game to act as the server for a client-server match.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void ChooseBestHostingPlayer(Action <GKPlayer> completionHandler)
 {
     C.GKMatch_chooseBestHostingPlayer(
         SelfPtr(),
         InternalChooseBestHostingPlayerCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Loads information from Game Center about a list of players.
 /// </summary>
 /// <param name="identifiers">Identifiers.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public static void LoadPlayersForIdentifiers(string[] identifiers, Action <GKPlayer[], NSError> completionHandler)
 {
     C.GKPlayer_loadPlayersForIdentifiers(
         identifiers, identifiers.Length,
         InternalLoadPlayersForIdentifiersCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Queries Game Center for the activity in a player group.
 /// </summary>
 /// <param name="playerGroup">Player group.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void QueryPlayerGroupActivity(uint playerGroup, Action <int, NSError> completionHandler)
 {
     C.GKMatchmaker_queryPlayerGroupActivity(
         SelfPtr(),
         playerGroup,
         IntErrorCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Resigns the player from the match when that player is not the current player. This action does not end the match.
 /// </summary>
 /// <param name="matchOutcome">Match outcome.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void ParticipantQuitOutOfTurn(GKTurnBasedParticipant.GKTurnBasedMatchOutcome matchOutcome, Action <NSError> completionHandler)
 {
     C.GKTurnBasedMatch_participantQuitOutOfTurn(
         SelfPtr(),
         ref matchOutcome,
         InternalErrorOnlyCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Requests access to the user's contacts.
 /// </summary>
 /// <param name="entityType">Entity type.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void RequestAccessForEntityType(CNEntityType entityType, Action <bool, NSError> completionHandler)
 {
     C.CNContactStore_requestAccessForEntityType(
         SelfPtr(),
         entityType,
         InternalRequestAccessForEntityTypeCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Loads a photo of this player from Game Center.
 /// </summary>
 /// <param name="photoSize">Photo size.</param>
 /// <param name="callback">Callback.</param>
 public void LoadPhotoForSize(GKPhotoSize photoSize, Action <UIImage, NSError> completionHandler)
 {
     C.GKPlayer_loadPhotoForSize(
         SelfPtr(),
         photoSize,
         InternalLoadPhotoForSizeCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Dismisses the view controller that was presented modally by the view controller.
 /// </summary>
 /// <param name="animated">If set to <c>true</c> animated.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void DismissViewController(bool animated, Action completionHandler)
 {
     C.UIViewController_dismissViewController(
         SelfPtr(),
         animated,
         completionHandler == null ? (C.DismissViewControllerCallback)null : InternalDismissViewControllerCallback,
         completionHandler == null ? IntPtr.Zero : PInvokeCallbackUtil.ToIntPtr(completionHandler)
         );
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Adds the specified image to the user’s Camera Roll album.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public static void UIImageWriteToSavedPhotosAlbum(UIImage image, Action <UIImage, NSError> completionHandler)
        {
            Util.NullArgumentTest(image);

            C.UIKit_UIImageWriteToSavedPhotosAlbum(
                image.ToPointer(),
                WriteToSavedPhotosAlbumCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Programmatically searches for a new match to join.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public static void FindMatchForRequest(GKMatchRequest request, Action <GKTurnBasedMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKTurnBasedMatch_findMatchForRequest(
                request.ToPointer(),
                InternalSingleMatchCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates a match from an accepted invitation.
        /// </summary>
        /// <param name="invite">Invite.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void MatchForInvite(GKInvite invite, Action <GKMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(invite);

            C.GKMatchmaker_matchForInvite(
                SelfPtr(),
                invite.ToPointer(),
                MatchErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Presents a view controller modally.
 /// </summary>
 /// <param name="viewController">View controller.</param>
 /// <param name="animated">If set to <c>true</c> animated.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void PresentViewController(UIViewController viewController, bool animated, Action completionHandler)
 {
     C.UIViewController_presentViewController(
         SelfPtr(),
         viewController.ToPointer(),
         animated,
         completionHandler == null ? (C.PresentViewControllerCallback)null : InternalPresentViewControllerCallback,
         completionHandler == null ? IntPtr.Zero : PInvokeCallbackUtil.ToIntPtr(completionHandler)
         );
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Initiates a request to find players for a peer-to-peer match.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void FindMatchForRequest(GKMatchRequest request, Action <GKMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKMatchmaker_findMatchForRequest(
                SelfPtr(),
                request.ToPointer(),
                MatchErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Initiates a request to find players for a hosted match.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void FindPlayersForHostedRequest(GKMatchRequest request, Action <NSArray <GKPlayer>, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKMatchmaker_findPlayersForHostedRequest(
                SelfPtr(),
                request.ToPointer(),
                PlayersErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Ends the match.
        /// </summary>
        /// <param name="matchData">Match data.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void EndMatchInTurn(byte[] matchData, Action <NSError> completionHandler)
        {
            Util.NullArgumentTest(matchData);

            C.GKTurnBasedMatch_endMatchInTurn(
                SelfPtr(),
                matchData,
                matchData.Length,
                InternalErrorOnlyCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Adds players to an existing match.
        /// </summary>
        /// <param name="match">Match.</param>
        /// <param name="matchRequest">Match request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void AddPlayersToMatch(GKMatch match, GKMatchRequest matchRequest, Action <NSError> completionHandler)
        {
            Util.NullArgumentTest(match);
            Util.NullArgumentTest(matchRequest);

            C.GKMatchmaker_addPlayersToMatch(
                SelfPtr(),
                match.ToPointer(),
                matchRequest.ToPointer(),
                ErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 25
0
 private static void InternalOpenSavedGame(string name, Action <iOSGKSavedGame[]> callback)
 {
     iOSSavedGameNative._OpenSavedGame(
         name,
         InternalOpenSavedGameCallback,
         PInvokeCallbackUtil.ToIntPtr <OpenSavedGameResponse>(
             response =>
     {
         callback(response.GetResultSavedGames());
     },
             OpenSavedGameResponse.FromPointer
             )
         );
 }
Ejemplo n.º 26
0
        private static void InternalGetPendingNotificationRequests(Action <iOSNotificationRequest[]> callback)
        {
            Util.NullArgumentTest(callback);

            iOSNotificationNative._GetPendingNotificationRequests(
                InternalGetPendingNotificationRequestsCallback,
                PInvokeCallbackUtil.ToIntPtr <GetPendingNotificationRequestsResponse>(
                    response =>
            {
                callback(response.GetNotificationRequests());
            },
                    GetPendingNotificationRequestsResponse.FromPointer
                    )
                );
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Updates the data stored on Game Center for the current match.
        /// </summary>
        /// <param name="nextParticipants">Next participants.</param>
        /// <param name="timeout">Timeout.</param>
        /// <param name="matchData">Match data.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void EndTurn(GKTurnBasedParticipant[] nextParticipants, long timeout, byte[] matchData, Action <NSError> completionHandler)
        {
            Util.NullArgumentTest(nextParticipants);
            Util.NullArgumentTest(matchData);

            C.GKTurnBasedMatch_endTurn(
                SelfPtr(),
                nextParticipants.Select(p => p != null ? p.ToPointer() : IntPtr.Zero).ToArray(),
                nextParticipants.Length,
                timeout,
                matchData,
                matchData.Length,
                InternalErrorOnlyCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Ejemplo n.º 28
0
        private static void InternalGetNotificationResponse(string identifier, Action <iOSNotificationResponse> callback)
        {
            Helper.NullArgumentTest(callback);

            iOSNotificationNative._GetNotificationResponse(
                identifier,
                InternalGetNotificationResponseCallback,
                PInvokeCallbackUtil.ToIntPtr <iOSNotificationResponse>(
                    response =>
            {
                callback(response);
            },
                    iOSNotificationResponse.FromPointer
                    )
                );
        }
Ejemplo n.º 29
0
        internal static void InternalDeleteSavedGame(iOSGKSavedGame savedGame, Action <string> callback)
        {
            Util.NullArgumentTest(savedGame);
            Util.NullArgumentTest(callback);

            iOSSavedGameNative._DeleteSavedGame(
                savedGame.Name,
                InternalDeleteSavedGameCallback,
                PInvokeCallbackUtil.ToIntPtr <DeleteSavedGameResponse>(
                    response =>
            {
                callback(response.GetError());
            },
                    DeleteSavedGameResponse.FromPointer
                    )
                );
        }
Ejemplo n.º 30
0
        internal static void InternalLoadSavedGameData(iOSGKSavedGame savedGame, Action <byte[], string> callback)
        {
            Util.NullArgumentTest(savedGame);
            Util.NullArgumentTest(callback);

            iOSSavedGameNative._LoadSavedGameData(
                savedGame.ToPointer(),
                InternalLoadSavedGameDataCallback,
                PInvokeCallbackUtil.ToIntPtr <LoadSavedGameDataResponse>(
                    response =>
            {
                callback(response.GetData(), response.GetError());
            },
                    LoadSavedGameDataResponse.FromPointer
                    )
                );
        }