internal TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> participants = new List <Participant>(); string selfParticipantId = null; string pendingParticipantId = null; using (MultiplayerParticipant participant = this.PendingParticipant()) { if (participant != null) { pendingParticipantId = participant.Id(); } } foreach (MultiplayerParticipant participant2 in this.Participants()) { using (participant2) { using (NativePlayer player = participant2.Player()) { if ((player != null) && player.Id().Equals(selfPlayerId)) { selfParticipantId = participant2.Id(); } } participants.Add(participant2.AsParticipant()); } } return(new TurnBasedMatch(this.Id(), this.Data(), (this.MatchStatus() == GooglePlayGames.Native.Cwrapper.Types.MatchStatus.COMPLETED) && !this.HasRematchId(), selfParticipantId, participants, this.AvailableAutomatchSlots(), pendingParticipantId, ToTurnStatus(this.MatchStatus()), ToMatchStatus(pendingParticipantId, this.MatchStatus()), this.Variant(), this.Version())); }
internal GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> participants = new List <Participant>(); string selfParticipantId = (string)null; string pendingParticipantId = (string)null; using (MultiplayerParticipant multiplayerParticipant = this.PendingParticipant()) { if (multiplayerParticipant != null) { pendingParticipantId = multiplayerParticipant.Id(); } } foreach (MultiplayerParticipant participant in this.Participants()) { using (participant) { using (NativePlayer nativePlayer = participant.Player()) { if (nativePlayer != null) { if (nativePlayer.Id().Equals(selfPlayerId)) { selfParticipantId = participant.Id(); } } } participants.Add(participant.AsParticipant()); } } return(new GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch(this.Id(), this.Data(), this.MatchStatus() == Types.MatchStatus.COMPLETED && !this.HasRematchId(), selfParticipantId, participants, this.AvailableAutomatchSlots(), pendingParticipantId, NativeTurnBasedMatch.ToTurnStatus(this.MatchStatus()), NativeTurnBasedMatch.ToMatchStatus(pendingParticipantId, this.MatchStatus()), this.Variant(), this.Version())); }
internal GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> list = new List <Participant>(); string selfParticipantId = null; string pendingParticipantId = null; using (MultiplayerParticipant multiplayerParticipant = PendingParticipant()) { if (multiplayerParticipant != null) { pendingParticipantId = multiplayerParticipant.Id(); } } foreach (MultiplayerParticipant item in Participants()) { using (item) { using (NativePlayer nativePlayer = item.Player()) { if (nativePlayer != null && nativePlayer.Id().Equals(selfPlayerId)) { selfParticipantId = item.Id(); } } list.Add(item.AsParticipant()); } } bool canRematch = MatchStatus() == Types.MatchStatus.COMPLETED && !HasRematchId(); return(new GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch(Id(), Data(), canRematch, selfParticipantId, list, AvailableAutomatchSlots(), pendingParticipantId, ToTurnStatus(MatchStatus()), ToMatchStatus(pendingParticipantId, MatchStatus()), Variant(), Version())); }
internal Participant AsParticipant() { NativePlayer nativePlayer = Player(); return(new Participant( DisplayName(), Id(), StatusConversion[Status()], nativePlayer == null ? null : nativePlayer.AsPlayer(), IsConnectedToRoom() )); }
internal void HandleFetchResponse(FetchResponseCollector collector, FetchResponse resp) { if (resp.Status() == CommonErrorStatus.ResponseStatus.VALID || resp.Status() == CommonErrorStatus.ResponseStatus.VALID_BUT_STALE) { NativePlayer player = resp.GetPlayer(); collector.results.Add(player); } collector.pendingCount--; if (collector.pendingCount == 0) { collector.callback(collector.results.ToArray()); } }
internal GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch AsTurnBasedMatch(string selfPlayerId) { List <Participant> participants = new List <Participant>(); string selfParticipantId = null; string pendingParticipantId = null; using (GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant = this.PendingParticipant()) { if (participant != null) { pendingParticipantId = participant.Id(); } } IEnumerator <GooglePlayGames.Native.PInvoke.MultiplayerParticipant> enumerator = this.Participants().GetEnumerator(); try { while (enumerator.MoveNext()) { GooglePlayGames.Native.PInvoke.MultiplayerParticipant current = enumerator.Current; using (current) { using (NativePlayer player = current.Player()) { if ((player != null) && player.Id().Equals(selfPlayerId)) { selfParticipantId = current.Id(); } } participants.Add(current.AsParticipant()); continue; } } } finally { if (enumerator == null) { } enumerator.Dispose(); } return(new GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch(this.Id(), this.Data(), (this.MatchStatus() == GooglePlayGames.Native.Cwrapper.Types.MatchStatus.COMPLETED) && !this.HasRematchId(), selfParticipantId, participants, this.AvailableAutomatchSlots(), pendingParticipantId, ToTurnStatus(this.MatchStatus()), ToMatchStatus(pendingParticipantId, this.MatchStatus()), this.Variant(), this.Version())); }
internal Participant AsParticipant() { NativePlayer player = this.Player(); return(new Participant(this.DisplayName(), this.Id(), StatusConversion[this.Status()], player?.AsPlayer(), this.IsConnectedToRoom())); }
internal Participant AsParticipant() { NativePlayer nativePlayer = this.Player(); return(new Participant(this.DisplayName(), this.Id(), MultiplayerParticipant.StatusConversion[this.Status()], nativePlayer != null ? nativePlayer.AsPlayer() : (GooglePlayGames.BasicApi.Multiplayer.Player)null, this.IsConnectedToRoom())); }