public void UpdateMatchInfo(ITurnBasedMatch match) { mMatch = match; if (mMatch != null && mMatch.GetData() != null) { pClickCount = BitConverter.ToInt32(mMatch.GetData(), 0); } else { pClickCount = 0; } }
// BEGIN IOnTurnBasedMatchUpdateReceivedListener // public void OnTurnBasedMatchReceived(ITurnBasedMatch match) { mMatch.UpdateMatchInfo(match); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); // Check if this was the error code we supplied. That is the only one we care about. if (requestCode == REQUEST_CODE_RESOLVE_ERR && resultCode == Result.Ok) { // TODO: Is google API the only one who sends REQUEST_CODE_RESOLVE_ERR? mGoogleApiClient.Connect(); return; } else if (requestCode == RC_SELECT_PLAYERS) { if (resultCode != Result.Ok) { Toast.MakeText(this, "Player Did Not Accept Invite", ToastLength.Long).Show(); // user canceled return; } // get the invitee list IList <string> invitees = data.GetStringArrayListExtra(Android.Gms.Games.GamesClass.ExtraPlayerIds); // get auto-match criteria Bundle autoMatchCriteria = null; int minAutoMatchPlayers = data.GetIntExtra(Multiplayer.ExtraMinAutomatchPlayers, 0); int maxAutoMatchPlayers = data.GetIntExtra(Multiplayer.ExtraMaxAutomatchPlayers, 0); if (minAutoMatchPlayers > 0) { autoMatchCriteria = RoomConfig.CreateAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0); } else { autoMatchCriteria = null; } TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.InvokeBuilder().AddInvitedPlayers(invitees).SetAutoMatchCriteria(autoMatchCriteria).Build(); // kick the match off GamesClass.TurnBasedMultiplayer.CreateMatch(mGoogleApiClient, tbmc).SetResultCallback(this); } else if (requestCode == RC_OPEN_INBOX) { if (resultCode != Result.Ok) { Toast.MakeText(this, "Inbox not ok", ToastLength.Long).Show(); // user canceled return; } try { ITurnBasedMatch match = Java.Lang.Object.GetObject <ITurnBasedMatch>(data.GetParcelableExtra(Multiplayer.ExtraTurnBasedMatch).Handle, JniHandleOwnership.DoNotTransfer); mMatch.UpdateMatchInfo(match); } catch { Toast.MakeText(this, "Failed to cast Match", ToastLength.Long).Show(); } } }