Exemplo n.º 1
0
    private void OnLoadMatchResult(string data)
    {
        GK_TBM_Match           match  = ParceMatchInfo(data);
        GK_TBM_LoadMatchResult result = new GK_TBM_LoadMatchResult(match);

        ActionMatchInfoLoaded(result);
    }
Exemplo n.º 2
0
    private void OnPlayerQuitForMatch(string data)
    {
        GK_TBM_Match match = ParceMatchInfo(data);

        UpdateMatchInfo(match);
        ActionPlayerQuitForMatch(match);
    }
Exemplo n.º 3
0
	// --------------------------------------
	// Private Methods
	// --------------------------------------

	private void UpdateMatchInfo(GK_TBM_Match match) {
		if (_Matches.ContainsKey(match.Id)) {
			_Matches[match.Id] = match;
		} else {
			_Matches.Add(match.Id, match);
		}
	}
Exemplo n.º 4
0
	// --------------------------------------
	// 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);
	}
Exemplo n.º 5
0
	private void OnRematchResult(string data) {
		GK_TBM_Match match = ParceMatchInfo(data);
		UpdateMatchInfo(match);
		
		GK_TBM_RematchResult result = new GK_TBM_RematchResult(match);
		ActionRematched(result);
	}
Exemplo n.º 6
0
	private void OnEndMatch(string data) {
		GK_TBM_Match match = ParceMatchInfo(data);
		UpdateMatchInfo(match);
		
		GK_TBM_MatchEndResult result = new GK_TBM_MatchEndResult(match);
		ActionMacthEnded(result);
	}
Exemplo n.º 7
0
	// --------------------------------------
	// 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);
	}
Exemplo n.º 8
0
    void HandleActionPlayerQuitForMatch(GK_TBM_Match match)
    {
        Debug.Log("GK_TBM_Controller::HandleActionPlayerQuitForMatch");

        ISN_Result r = new ISN_Result(true);

        SendMatchUpdateEvent(r, match);
    }
Exemplo n.º 9
0
    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);
    }
Exemplo n.º 10
0
    private void OnMatchFoundResult(string data)
    {
        GK_TBM_Match match = ParceMatchInfo(data);

        UpdateMatchInfo(match);
        GK_TBM_MatchInitResult result = new GK_TBM_MatchInitResult(match);

        ActionMatchFound(result);
    }
Exemplo n.º 11
0
    private void OnMatchInvitationAccepted(string data)
    {
        GK_TBM_Match match = ParceMatchInfo(data);

        UpdateMatchInfo(match);
        GK_TBM_MatchInitResult result = new GK_TBM_MatchInitResult(match);

        ActionMatchInvitationAccepted(result);
    }
Exemplo n.º 12
0
    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);
    }
Exemplo n.º 13
0
    //--------------------------------------
    // 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);
    }
Exemplo n.º 14
0
    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;
        }
    }
Exemplo n.º 15
0
	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);
	}
Exemplo n.º 16
0
    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);
    }
Exemplo n.º 17
0
	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);
        }
    }
Exemplo n.º 19
0
    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);
    }
Exemplo n.º 20
0
	public GK_TBM_EndTrunResult(GK_TBM_Match match):base(true) {
		_Match = match;
	}
Exemplo n.º 21
0
 public GK_TBM_MatchEndResult(GK_TBM_Match match) : base()
 {
     _Match = match;
 }
 public GK_TBM_MatchTurnResult(GK_TBM_Match match) : base(true)
 {
     _Match = match;
 }
Exemplo n.º 23
0
	public GK_TBM_LoadMatchResult(GK_TBM_Match match):base(true) {
		_Match = match;
	}
Exemplo n.º 24
0
 public UM_TBM_Invite(GK_TBM_Match match)
 {
     _Id = match.Id;
     _CreationTimestamp = match.CreationTimestamp;
     _Inviter           = new UM_TBM_Participant(match.Participants[0]);
 }
Exemplo n.º 25
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;
 }
Exemplo n.º 27
0
 public GK_TBM_RematchResult(GK_TBM_Match match) : base()
 {
     _Match = match;
 }
Exemplo n.º 28
0
	public GK_TBM_MatchTurnResult(GK_TBM_Match match):base(true) {
		_Match = match;
	}
Exemplo n.º 29
0
 public GK_TBM_LoadMatchResult(GK_TBM_Match match) : base(true)
 {
     _Match = match;
 }
Exemplo n.º 30
0
 public GK_TBM_EndTrunResult(GK_TBM_Match match) : base(true)
 {
     _Match = match;
 }
Exemplo n.º 31
0
	public GK_TBM_MatchInitResult(GK_TBM_Match match):base(true) {
		_Match = match;
	}
	public GK_TBM_MatchDataUpdateResult(GK_TBM_Match updatedMatch):base(true) {
		_Match = updatedMatch;
	}