/// <summary> /// Brings up the match making interface to start a real-time match with other players. /// Raises MatchMakerFoundMatch, MatchMakerCancelled, and MatchMakerFailed events. /// </summary> /// <param name="minPlayers">The minimum nubmer of players that can join a match; between 2 and 4 inclusively.</param> /// <param name="maxPlayers">The maximum number of players that can join a match; between 2 and 4 inclusively.</param> /// <param name="playerGroup">The group this player belongs to such as skill level; Game Center will match players with the same playerGroup.</param> /// <param name="playerAttributes">The attributes of this player such as white or black pieces in chest; Game Center will try to match players so that all bits of this attribute are filled by all players of a game.</param> /// <param name="playersToInvite">An array of Player instances; this is passed in from the PlayersInvited event.</param> public static void StartMatch(uint minPlayers, uint maxPlayers, uint playerGroup = 0, uint playerAttributes = 0, Player[] playersToInvite = null) { if ((minPlayers < 2) || (minPlayers > 4) || (maxPlayers < 2) || (maxPlayers > 4) || (maxPlayers < minPlayers)) { throw new U3DXTException("minPlayers and maxPlayers must be between 2 and 4."); } _currentMatch = null; // create request var request = new GKMatchRequest(); request.minPlayers = minPlayers; request.maxPlayers = maxPlayers; request.playerGroup = playerGroup; request.playerAttributes = playerAttributes; if (playersToInvite != null) { request.playersToInvite = Player.PlayersToIDs(playersToInvite); } // create view controller var mmvc = new GKMatchmakerViewController(request); // set delegate mmvc.matchmakerDelegate = MatchmakerViewControllerDelegate.instance; // show it UIApplication.deviceRootViewController.PresentViewController(mmvc, true, null); }
internal static void _OnMatchMakerCancelled() { _currentMatch = null; if (_matchMakerCancelledHandlers != null) { _matchMakerCancelledHandlers(null, EventArgs.Empty); } }
internal static void _OnMatchMakerFailed(NSError error) { _currentMatch = null; if (_matchMakerFailedHandlers != null) { _matchMakerFailedHandlers(null, new U3DXTErrorEventArgs(error)); } }
void OnDestroy() { // disconnect the match match.Disconnect(); match = null; // manually remove this participant RemoveParticipant(GameKitXT.localPlayer); }
/// <summary> /// U3DXT internal. /// </summary> /// <returns>The current match.</returns> /// <param name="">.</param> public static void SetCurrentMatch(GKMatch gkMatch) { if (gkMatch == null) { _currentMatch = null; return; } // resolve to wrapper and then dispatch event var rtmatch = NSObjectWrapper.CreateWrapper(typeof(RealTimeMatch), gkMatch) as RealTimeMatch; gkMatch = null; rtmatch.ReloadPlayers(delegate() { _currentMatch = rtmatch; if (_matchMakerFoundMatchHandlers != null) { _matchMakerFoundMatchHandlers(null, new MatchEventArgs(rtmatch)); } rtmatch = null; }); }
void Start() { match = RealTimeMatchesController.currentMatch; // add local player and then other players AddParticipant(GameKitXT.localPlayer); foreach (var player in match.players) { AddParticipant(player); } // subscribe to events match.DataReceived += OnReceiveData; match.PlayerStateChanged += OnPlayerStateChanged; // start voice chat var voiceChat = match.GetVoiceChat("all"); voiceChat.PlayerStateChanged += OnVoiceChatPlayerStateChanged; voiceChat.Join(); voiceChat.isTalking = true; }
internal static void _OnMatchMakerFailed(NSError error) { _currentMatch = null; if (_matchMakerFailedHandlers != null) _matchMakerFailedHandlers(null, new U3DXTErrorEventArgs(error)); }
internal static void _OnMatchMakerCancelled() { _currentMatch = null; if (_matchMakerCancelledHandlers != null) _matchMakerCancelledHandlers(null, EventArgs.Empty); }
/// <summary> /// Brings up the match making interface to start a real-time match with other players. /// Raises MatchMakerFoundMatch, MatchMakerCancelled, and MatchMakerFailed events. /// </summary> /// <param name="minPlayers">The minimum nubmer of players that can join a match; between 2 and 4 inclusively.</param> /// <param name="maxPlayers">The maximum number of players that can join a match; between 2 and 4 inclusively.</param> /// <param name="playerGroup">The group this player belongs to such as skill level; Game Center will match players with the same playerGroup.</param> /// <param name="playerAttributes">The attributes of this player such as white or black pieces in chest; Game Center will try to match players so that all bits of this attribute are filled by all players of a game.</param> /// <param name="playersToInvite">An array of Player instances; this is passed in from the PlayersInvited event.</param> public static void StartMatch(uint minPlayers, uint maxPlayers, uint playerGroup = 0, uint playerAttributes = 0, Player[] playersToInvite = null) { if ((minPlayers < 2) || (minPlayers > 4) || (maxPlayers < 2) || (maxPlayers > 4) || (maxPlayers < minPlayers)) throw new U3DXTException("minPlayers and maxPlayers must be between 2 and 4."); _currentMatch = null; // create request var request = new GKMatchRequest(); request.minPlayers = minPlayers; request.maxPlayers = maxPlayers; request.playerGroup = playerGroup; request.playerAttributes = playerAttributes; if (playersToInvite != null) request.playersToInvite = Player.PlayersToIDs(playersToInvite); // create view controller var mmvc = new GKMatchmakerViewController(request); // set delegate mmvc.matchmakerDelegate = MatchmakerViewControllerDelegate.instance; // show it UIApplication.deviceRootViewController.PresentViewController(mmvc, true, null); }
/// <summary> /// U3DXT internal. /// </summary> /// <returns>The current match.</returns> /// <param name="">.</param> public static void SetCurrentMatch(GKMatch gkMatch) { if (gkMatch == null) { _currentMatch = null; return; } // resolve to wrapper and then dispatch event var rtmatch = NSObjectWrapper.CreateWrapper(typeof(RealTimeMatch), gkMatch) as RealTimeMatch; gkMatch = null; rtmatch.ReloadPlayers(delegate() { _currentMatch = rtmatch; if (_matchMakerFoundMatchHandlers != null) _matchMakerFoundMatchHandlers(null, new MatchEventArgs(rtmatch)); rtmatch = null; }); }