예제 #1
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);
    }
예제 #2
0
    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;
            }
        }
    }
    void Start()
    {
        _ghost = gameObject.AddComponent <RS_GhostCarManager> ();

        RS_CarFactory.CarLoadedAction += RS_CarFactory_CarLoadedAction;
        if (Mode == RS_GameMode.Multiplayer)
        {
            ActiveMatchData = new ST_TBM_MatchData(ActiveMatch);
            RS_CarFactory.CreateCar(ActiveMatchData.CompetitorReplay != null ? ActiveMatchData.CompetitorReplay.CarId : RS_GameData.MenuCarId, RS_CarCreationMode.Garage);

            _netController = gameObject.AddComponent <MultiplayerGameController> ();
                        #if !UNITY_EDITOR
            _netController.InitMatchData(ActiveMatch);
                        #endif
        }
        else
        {
            RS_CarFactory.CreateCar(RS_GameData.MenuCarId, RS_CarCreationMode.Garage);
        }
    }
    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");
        }
    }
 public void InitMatchData(UM_TBM_Match match)
 {
     matchData = new ST_TBM_MatchData(match);
     Debug.Log("Match data intialized");
 }
    private void HandleOnLevelFinishedAction()
    {
        Debug.Log("[GhostController] HandleOnLevelFinishedAction");
        RS_GamePlayController.Instance.OnLevelFinishedAction -= HandleOnLevelFinishedAction;
        RS_GamePlayController.Instance.OnPlayerSpawned       -= HandleOnSpawnPlayer;
        RS_CarFactory.CarLoadedAction -= HandleActionGhostCarLoaded;

        NewGhostData.SetFinishTime(RaceTimer.Instance.GetCurrentGlobalTime());
        NewGhostData.AddDataBundle(TemporaryBundleList);
        TemporaryBundleList.Clear();

        if (RS_GamePlayController.Mode == RS_GameMode.Multiplayer)
        {
            //Take Turn of finish the Match
            Debug.Log(RS_GamePlayController.Mode.ToString() + " Time to make a Turn...");
                        #if !UNITY_EDITOR
            MultiplayerReplayData replayData = new MultiplayerReplayData(RS_GamePlayController.Instance.Multiplayer.CurrentMatch.LocalParticipant.Id, NewGhostData);
            RS_GamePlayController.Instance.Multiplayer.MatchData.SetParticipantData(replayData);

            ST_TBM_MatchData match = RS_GamePlayController.Instance.Multiplayer.MatchData;

            Debug.Log("MATCH STATUS: " + match.Match.Status.ToString());
            Debug.Log("MATCH IsLocalPlayerTurn: " + match.Match.IsLocalPlayerTurn.ToString());

            foreach (UM_TBM_Participant player in match.Match.Participants)
            {
                Debug.Log("[PARTICIPANT] " + player.Id +
                          "\t\n" + player.DisplayName +
                          "\t\n" + player.Status.ToString());
            }

            if (RS_GamePlayController.Instance.Multiplayer.CurrentMatch.Competitor != null &&
                RS_GamePlayController.Instance.Multiplayer.CurrentMatch.Competitor.Status != UM_TBM_ParticipantStatus.Unknown)
            {
                if (match.LocalPlayerTime > match.CompetitorTime)
                {
                    match.Loose();
                }
                else if (match.LocalPlayerTime < match.CompetitorTime)
                {
                    match.Win();
                }
                else
                {
                    match.Tie();
                }
            }
            else
            {
                match.TakeTrun();
            }
                        #else
            Debug.Log("But, wait! We are in Editor Mode.");
                        #endif
        }
        else
        {
            if (LoadedGhostData != null)
            {
                if (LoadedGhostData.FinishTime >= NewGhostData.FinishTime)
                {
                    Debug.Log("[Saving ghost data locally]");
                    Debug.Log(NewGhostData.CarId);
                    Debug.Log(NewGhostData.CarLevel);
                    Debug.Log(NewGhostData.RawData.ToString() + " Count:" + NewGhostData.RawData.Count);

                    NewGhostData.SaveLocalRecord();
                }
            }
            else
            {
                Debug.Log("[Saving ghost data locally]");
                Debug.Log(NewGhostData.CarId);
                Debug.Log(NewGhostData.CarLevel);
                Debug.Log(NewGhostData.RawData.ToString() + " Count:" + NewGhostData.RawData.Count);

                NewGhostData.SaveLocalRecord();
            }
        }
    }