private void OnLoadMatchResult(string data) { GK_TBM_Match match = ParceMatchInfo(data); GK_TBM_LoadMatchResult result = new GK_TBM_LoadMatchResult(match); ActionMatchInfoLoaded(result); }
private void OnPlayerQuitForMatch(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); ActionPlayerQuitForMatch(match); }
// -------------------------------------- // Private Methods // -------------------------------------- private void UpdateMatchInfo(GK_TBM_Match match) { if (_Matches.ContainsKey(match.Id)) { _Matches[match.Id] = match; } else { _Matches.Add(match.Id, match); } }
// -------------------------------------- // GK Turn-Based Event Listener // -------------------------------------- private void OnTrunReceived(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); GK_TBM_MatchTurnResult result = new GK_TBM_MatchTurnResult(match); ActionTrunReceived(result); }
private void OnRematchResult(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); GK_TBM_RematchResult result = new GK_TBM_RematchResult(match); ActionRematched(result); }
private void OnEndMatch(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); GK_TBM_MatchEndResult result = new GK_TBM_MatchEndResult(match); ActionMacthEnded(result); }
// -------------------------------------- // Native Events // -------------------------------------- public void OnLoadMatchesResult(string data) { Debug.Log("TBM::OnLoadMatchesResult: " + data); GK_TBM_LoadMatchesResult result = new GK_TBM_LoadMatchesResult(true); _Matches = new Dictionary<string, GK_TBM_Match>(); if(data.Length == 0) { ActionMatchesInfoLoaded(result); return; } string[] DataArray = data.Split(new string[] { IOSNative.DATA_SPLITTER2 }, StringSplitOptions.None); if (DataArray.Length > 0) { result.LoadedMatches = new Dictionary<string, GK_TBM_Match>(); for (int i = 0; i < DataArray.Length; i++) { if (DataArray[i] == IOSNative.DATA_EOF) { break; } GK_TBM_Match match = ParceMatchInfo(DataArray[i]); UpdateMatchInfo(match); result.LoadedMatches.Add(match.Id, match); } } ActionMatchesInfoLoaded(result); }
void HandleActionPlayerQuitForMatch(GK_TBM_Match match) { Debug.Log("GK_TBM_Controller::HandleActionPlayerQuitForMatch"); ISN_Result r = new ISN_Result(true); SendMatchUpdateEvent(r, match); }
void HandleActionPlayerQuitForMatch(GK_TBM_Match match) { Debug.Log("GK_TBM_Controller::HandleActionPlayerQuitForMatch"); SA.Common.Models.Result r = new SA.Common.Models.Result(); SendMatchUpdateEvent(r, match); }
private void OnMatchFoundResult(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); GK_TBM_MatchInitResult result = new GK_TBM_MatchInitResult(match); ActionMatchFound(result); }
private void OnMatchInvitationAccepted(string data) { GK_TBM_Match match = ParceMatchInfo(data); UpdateMatchInfo(match); GK_TBM_MatchInitResult result = new GK_TBM_MatchInitResult(match); ActionMatchInvitationAccepted(result); }
public static void PrintMatchInfo(GK_TBM_Match match) { string MatchInfo = string.Empty; MatchInfo = MatchInfo + "----------------------------------------" + "\n"; MatchInfo = MatchInfo + "Printing basic match info, for " + "\n"; MatchInfo = MatchInfo + "Match ID: " + match.Id + "\n"; MatchInfo = MatchInfo + "Status:" + match.Status + "\n"; if (match.CurrentParticipant != null) { if (match.CurrentParticipant.Player != null) { MatchInfo = MatchInfo + "CurrentPlayerID: " + match.CurrentParticipant.Player.Id + "\n"; } else { MatchInfo = MatchInfo + "CurrentPlayerID: ---- \n"; } } else { MatchInfo = MatchInfo + "CurrentPlayerID: ---- \n"; } MatchInfo = MatchInfo + "Data: " + match.UTF8StringData + "\n"; MatchInfo = MatchInfo + "*******Participants*******" + "\n"; foreach (GK_TBM_Participant p in match.Participants) { if (p.Player != null) { MatchInfo = MatchInfo + "PlayerId: " + p.Player.Id + "\n"; } else { MatchInfo = MatchInfo + "PlayerId: --- \n"; } MatchInfo = MatchInfo + "Status: " + p.Status + "\n"; MatchInfo = MatchInfo + "MatchOutcome: " + p.MatchOutcome + "\n"; MatchInfo = MatchInfo + "TimeoutDate: " + p.TimeoutDate.ToString("DD MMM YYYY HH:mm:ss") + "\n"; MatchInfo = MatchInfo + "LastTurnDate: " + p.LastTurnDate.ToString("DD MMM YYYY HH:mm:ss") + "\n"; MatchInfo = MatchInfo + "**********************" + "\n"; } MatchInfo = MatchInfo + "----------------------------------------" + "\n"; ISN_Logger.Log(MatchInfo); }
//-------------------------------------- // Private Methods //-------------------------------------- public void SendMatchUpdateEvent(SA.Common.Models.Result res, GK_TBM_Match match) { UM_TBM_MatchResult result = new UM_TBM_MatchResult(res); if (match != null) { UM_TBM_Match m = new UM_TBM_Match(match); result.SetMatch(m); UpdateMatchData(m); } MatchUpdatedEvent(result); }
public UM_TBM_Match(GK_TBM_Match match) { _Id = match.Id; _Data = match.Data; foreach (GK_TBM_Participant participant in match.Participants) { UM_TBM_Participant p = new UM_TBM_Participant(participant); _Participants.Add(p); } if (match.CurrentParticipant != null) { _CurrentParticipant = new UM_TBM_Participant(match.CurrentParticipant); if (_CurrentParticipant.Playerid.Equals(GameCenterManager.Player.Id)) { _IsCurrentPlayerTurn = true; } } switch (match.Status) { case GK_TurnBasedMatchStatus.Unknown: _Status = UM_TBM_MatchStatus.Unknown; break; case GK_TurnBasedMatchStatus.Open: _Status = UM_TBM_MatchStatus.Active; break; case GK_TurnBasedMatchStatus.Matching: _Status = UM_TBM_MatchStatus.Matching; break; case GK_TurnBasedMatchStatus.Ended: _Status = UM_TBM_MatchStatus.Ended; break; } }
private void OnUpdateMatchResult(string data) { string[] DataArray = data.Split(IOSNative.DATA_SPLITTER[0]); GK_TBM_MatchDataUpdateResult result; string matchId = DataArray[0]; GK_TBM_Match m = GetMatchById(matchId); if(m == null) { result = new GK_TBM_MatchDataUpdateResult(); ISN_Error e = new ISN_Error(); e.code = 0; e.description = "Match with id: " + matchId + " not found"; result.SetError(e); Debug.LogWarning(e.description); } else { m.SetData(DataArray[1]); result = new GK_TBM_MatchDataUpdateResult(m); } ActionMatchDataUpdated(result); }
private void OnUpdateMatchResult(string data) { string[] DataArray = data.Split(SA.Common.Data.Converter.DATA_SPLITTER); GK_TBM_MatchDataUpdateResult result; string matchId = DataArray[0]; GK_TBM_Match m = GetMatchById(matchId); if (m == null) { SA.Common.Models.Error e = new SA.Common.Models.Error(0, "Match with id: " + matchId + " not found"); result = new GK_TBM_MatchDataUpdateResult(e); } else { m.SetData(DataArray[1]); result = new GK_TBM_MatchDataUpdateResult(m); } ActionMatchDataUpdated(result); }
public static GK_TBM_Match ParceMatchInfo(string[] MatchData, int index) { GK_TBM_Match mtach = new GK_TBM_Match(); mtach.Id = MatchData[index]; mtach.Status = (GK_TurnBasedMatchStatus) System.Convert.ToInt64(MatchData[index + 1]) ; mtach.Message = MatchData[index + 2]; mtach.CreationTimestamp = DateTime.Parse(MatchData[index + 3]); mtach.SetData(MatchData[index + 4]); string currentPlayerId = MatchData[index + 5]; mtach.Participants = GameCenterManager.ParseParticipantsData(MatchData, index + 6); foreach(GK_TBM_Participant participant in mtach.Participants) { participant.SetMatchId(mtach.Id); } mtach.CurrentParticipant = mtach.GetParticipantByPlayerId(currentPlayerId); return mtach; }
public void ActionMatchesResultLoaded(GK_TBM_LoadMatchesResult res) { GameCenter_TBM.ActionMatchesInfoLoaded -= ActionMatchesResultLoaded; ISN_Logger.Log("ActionMatchesResultLoaded: " + res.IsSucceeded); if (res.IsFailed) { return; } if (res.LoadedMatches.Count == 0) { return; } foreach (KeyValuePair <string, GK_TBM_Match> pair in res.LoadedMatches) { GK_TBM_Match m = pair.Value; GameCenter_TBM.PrintMatchInfo(m); } }
void HandleActionMatchesInfoLoaded(GK_TBM_LoadMatchesResult res) { UM_TBM_MatchesLoadResult result = new UM_TBM_MatchesLoadResult(res); if (res.IsSucceeded) { _Matches.Clear(); _Invitations.Clear(); foreach (KeyValuePair <string, GK_TBM_Match> pair in res.LoadedMatches) { GK_TBM_Match match = pair.Value; if (match.LocalParticipant == null) { continue; } if (match.LocalParticipant.Status == GK_TurnBasedParticipantStatus.Invited) { UM_TBM_Invite invite = new UM_TBM_Invite(match); _Invitations.Add(invite); } else { UM_TBM_Match m = new UM_TBM_Match(match); _Matches.Add(m); } result.SetMatches(_Matches); result.SetInvitations(_Invitations); } } MatchesListUpdated(); MatchesListLoadedEvent(result); }
public GK_TBM_EndTrunResult(GK_TBM_Match match):base(true) { _Match = match; }
public GK_TBM_MatchEndResult(GK_TBM_Match match) : base() { _Match = match; }
public GK_TBM_MatchTurnResult(GK_TBM_Match match) : base(true) { _Match = match; }
public GK_TBM_LoadMatchResult(GK_TBM_Match match):base(true) { _Match = match; }
public UM_TBM_Invite(GK_TBM_Match match) { _Id = match.Id; _CreationTimestamp = match.CreationTimestamp; _Inviter = new UM_TBM_Participant(match.Participants[0]); }
public GK_TBM_MatchDataUpdateResult(GK_TBM_Match updatedMatch) : base(true) { _Match = updatedMatch; }
public GK_TBM_MatchInitResult(GK_TBM_Match match) : base(true) { _Match = match; }
public GK_TBM_RematchResult(GK_TBM_Match match) : base() { _Match = match; }
public GK_TBM_MatchTurnResult(GK_TBM_Match match):base(true) { _Match = match; }
public GK_TBM_LoadMatchResult(GK_TBM_Match match) : base(true) { _Match = match; }
public GK_TBM_EndTrunResult(GK_TBM_Match match) : base(true) { _Match = match; }
public GK_TBM_MatchInitResult(GK_TBM_Match match):base(true) { _Match = match; }
public GK_TBM_MatchDataUpdateResult(GK_TBM_Match updatedMatch):base(true) { _Match = updatedMatch; }