Beispiel #1
0
    //--------------------------------------
    // Private Methods
    //--------------------------------------



    private void UpdateMatchData(UM_TBM_Match match)
    {
        bool isFound = false;


        //autofinish
        if (match.IsEnded && match.IsLocalPlayerTurn)
        {
            GooglePlayTBM.Instance.ConfirmMatchFinish(match.Id);
        }

        for (int i = 0; i < Matches.Count; i++)
        {
            if (Matches[i].Id.Equals(match.Id))
            {
                isFound = true;

                Matches[i] = match;
            }
        }

        if (!isFound)
        {
            Matches.Add(match);
        }

        MatchesListUpdated();
    }
Beispiel #2
0
    public void SetMultiplayer(UM_TBM_Match match, float localPlayerTime)
    {
        NewRewardLabel.gameObject.SetActive(false);
        Tickets.text = RS_PlayerData.Instance.MultiplayerTickets + "/" + RS_PlayerData.MAX_TICKETS;
        Wins.text    = RS_PlayerData.Instance.MultiplayerWins.ToString();

        ST_TBM_MatchData data = new ST_TBM_MatchData(match);

        Car.text   = RS_PlayerData.Instance.GetCarTemplate(data.MyCarId).Title;
        Track.text = data.TrackId;

        if (data.CompetitorReplay != null)
        {
            Winner.SetInfo(UM_GameServiceManager.Instance.GetPlayer(match.LocalParticipant.Playerid), localPlayerTime, true, localPlayerTime - data.CompetitorTime);
            Loser.SetInfo(UM_GameServiceManager.Instance.GetPlayer(match.Competitor.Playerid), data.CompetitorTime, false, data.CompetitorTime - localPlayerTime);
        }
        else
        {
            Winner.SetInfo(UM_GameServiceManager.Instance.GetPlayer(match.LocalParticipant.Playerid), localPlayerTime, false);

            if (match.Competitor != null)
            {
                Loser.SetInfo(UM_GameServiceManager.Instance.GetPlayer(match.Competitor.Playerid), data.CompetitorTime, false, data.CompetitorTime - localPlayerTime);
            }
            else
            {
                Loser.SetEmpty(null);
            }
        }

        Winner.gameObject.SetActive(true);
        Loser.gameObject.SetActive(true);

        gameObject.SetActive(true);
    }
    public void SetMatchInfo(UM_TBM_Match match)
    {
        Debug.Log("[SetMatchInfo] match Id: " + match.Id);

        CurrentMatch = match;
        SetCompetitor(CurrentMatch.Competitor);

        ST_TBM_MatchData data = new ST_TBM_MatchData(match);

        if (match.Status == UM_TBM_MatchStatus.Ended)
        {
            bool iAmTheWinner = data.LocalPlayerTime <= data.CompetitorTime;
            if (iAmTheWinner)
            {
                RS_PlayerData.Instance.MultiplayerWins++;
                UM_GameServiceManager.Instance.SubmitScore("Most Wanted", RS_PlayerData.Instance.MultiplayerWins);
                _parent.TopPanelUI.UpdateWins();
            }

            Winner.gameObject.SetActive(iAmTheWinner);
            Loser.gameObject.SetActive(!iAmTheWinner);
            Track.text = data.TrackId;
            Car.text   = RS_PlayerData.Instance.GetCarTemplate(data.CompetitorReplay.CarId).Title;

            string prefix = iAmTheWinner ? "-" : "+";
            Timer.text      = GetTimeFormated(iAmTheWinner ? data.LocalPlayerTime : data.CompetitorTime);
            TimeDelay.text  = prefix + GetTimeFormated(Mathf.Abs(data.LocalPlayerTime - data.CompetitorTime));
            TimeDelay.color = iAmTheWinner ? WinningColor : LosingColor;
            TimeDelay.gameObject.SetActive(true);

            RematchButton.gameObject.SetActive(true);
        }
        else
        {
            Winner.gameObject.SetActive(false);
            Loser.gameObject.SetActive(false);

            TimeDelay.gameObject.SetActive(false);
            PlayButton.gameObject.SetActive(match.IsLocalPlayerTurn);

            if (data.CompetitorReplay != null)
            {
                Timer.text = GetTimeFormated(data.CompetitorTime);
                Track.text = data.TrackId;
                Car.text   = RS_PlayerData.Instance.GetCarTemplate(data.CompetitorReplay.CarId).Title;
            }
            else
            {
                Timer.text = GetTimeFormated(data.LocalPlayerTime);
                Track.text = data.TrackId;
                Car.text   = RS_PlayerData.Instance.GetCarTemplate(data.MyCarId).Title;
            }
        }
    }
Beispiel #4
0
    void HandleActionMatchDataLoaded(GP_TBM_LoadMatchResult res)
    {
        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.Match != null)
        {
            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            result.SetMatch(match);
            UpdateMatchData(match);
        }

        MatchLoadedEvent(result);
    }
Beispiel #5
0
    void HandleActionTurnFinished(GP_TBM_UpdateMatchResult res)
    {
        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.Match != null)
        {
            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            result.SetMatch(match);
            UpdateMatchData(match);
        }

        TurnEndedEvent(result);
    }
Beispiel #6
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);
    }
Beispiel #7
0
    //--------------------------------------
    // Action Handlers
    //--------------------------------------

    void HandleActionMatchInitiated(GP_TBM_MatchInitiatedResult res)
    {
        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.Match != null)
        {
            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            result.SetMatch(match);
            UpdateMatchData(match);
        }

        MatchFoundEvent(result);
    }
Beispiel #8
0
    void HandleActionMatchInfoLoaded(GK_TBM_LoadMatchResult res)
    {
        Debug.Log("GK_TBM_Controller::HandleActionMatchInfoLoaded");

        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.Match != null)
        {
            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            UpdateMatchData(match);
            result.SetMatch(match);
        }

        MatchLoadedEvent(result);
    }
Beispiel #9
0
    void HandleActionMatchesResultLoaded(GP_TBM_LoadMatchesResult res)
    {
        _Matches.Clear();

        if (res.IsSucceeded)
        {
            foreach (KeyValuePair <string, GP_TBM_Match> pair in res.LoadedMatches)
            {
                GP_TBM_Match match = pair.Value;
                UM_TBM_Match m     = new UM_TBM_Match(match);
                UpdateMatchData(m);
            }
        }

        CheckDataCounter();
    }
Beispiel #10
0
    void HandleActionMatchInvitationAccepted(GK_TBM_MatchInitResult res)
    {
        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.IsSucceeded)
        {
            RemoveInvitationsFromTheList(res.Match.Id);

            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            result.SetMatch(match);

            UpdateMatchData(match);
        }

        InvitationAccepted(result);
    }
Beispiel #11
0
    void HandleActionMatchInvitationAccepted(string invitationId, GP_TBM_MatchInitiatedResult res)
    {
        Debug.Log("GP_TBM_Controller::HandleActionMatchInvitationAccepted");


        UM_TBM_MatchResult result = new UM_TBM_MatchResult(res);

        if (res.IsSucceeded)
        {
            RemoveInvitationsFromTheList(invitationId);
            UM_TBM_Match match = new UM_TBM_Match(res.Match);
            result.SetMatch(match);

            UpdateMatchData(match);
            Debug.Log("GP_TBM_Controller::HandleActionMatchInvitationAccepted, list updated");
        }



        InvitationAccepted(result);
    }
Beispiel #12
0
    private void UpdateMatchData(UM_TBM_Match match)
    {
        bool isFound = false;

        for (int i = 0; i < Matches.Count; i++)
        {
            if (Matches[i].Id.Equals(match.Id))
            {
                isFound = true;

                Matches[i] = match;
            }
        }

        if (!isFound)
        {
            Matches.Add(match);
        }

        MatchesListUpdated();
    }
    public ST_TBM_MatchData(UM_TBM_Match match) : base(2)
    {
        _Match = match;

        if (_Match.Data.Length != 0)
        {
            try {
                Debug.Log("ST_TBM_MatchData initialized with  data: " + _Match.Data.Length);
                ST_TBM_MatchData ReceviedData = new ST_TBM_MatchData(_Match.Data);

                foreach (MultiplayerReplayData mrd in ReceviedData.ParticipantsData)
                {
                    SetParticipantData(mrd);
                }
            } catch (System.Exception ex) {
                Debug.Log("MatchData reading fail - " + ex.Message);
            }
        }
        else
        {
            Debug.Log("ST_TBM_MatchData initialized with empty data");
        }
    }
Beispiel #14
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);
    }
 public void ShowForMultiplayer(UM_TBM_Match match, float localPlayerTime)
 {
     WinnerScreen.SetMultiplayer(match, localPlayerTime);
 }
 public void InitMatchData(UM_TBM_Match match)
 {
     matchData = new ST_TBM_MatchData(match);
     Debug.Log("Match data intialized");
 }
Beispiel #17
0
    public void SetMatch(UM_TBM_Match match)
    {
        _Match = match;

        RemoveButton.SetActive(true);

        OponentIcon.sprite = Sprite.Create(DefaultOponentIcon, new Rect(0, 0, DefaultOponentIcon.width, DefaultOponentIcon.height), new Vector2(0.5f, 0.5f));
        Competitor         = _Match.Competitor;

        if (Competitor != null && Competitor.IsPlayerDefined)
        {
            OponentName.text             = Competitor.DisplayName;
            Competitor.SmallPhotoLoaded += HandleSmallPhotoLoaded;
            Competitor.LoadSmallPhoto();
        }
        else
        {
            OponentName.text = "Mtaching...";
        }

        if (match.Status == UM_TBM_MatchStatus.Ended)
        {
            WaitTag.gameObject.SetActive(true);
            WaitTag.text = match.LocalParticipant.Outcome.ToString();
        }
        else
        {
            if (match.IsLocalPlayerTurn)
            {
                PlayButton.SetActive(true);
            }
            else
            {
                WaitTag.gameObject.SetActive(true);
            }
        }

        string statusString = string.Empty;

        if (match.IsLocalPlayerTurn)
        {
            statusString = statusString + "Your Turn \n";
        }
        else
        {
            statusString = statusString + "Waiting for Opponent  Move \n";
        }

        statusString += "Opponent Status: ";
        if (match.Competitor != null)
        {
            statusString += match.Competitor.Status + "\n";
        }
        else
        {
            statusString += "Matching \n";
        }

        statusString += "Match: " + match.Status + "  ";

        statusString += match.LocalParticipant.Outcome.ToString() + " / ";
        if (match.Competitor != null)
        {
            statusString += match.Competitor.Outcome.ToString();
        }
        else
        {
            statusString += UM_TBM_Outcome.None.ToString();
        }


        MatchStatus.text = statusString;
    }
Beispiel #18
0
 public void SetMatch(UM_TBM_Match match)
 {
     _Match = match;
 }