Ejemplo n.º 1
0
        void OnPlayGame(string gameId)
        {
            _multiplayerWindow.OnPlay -= OnPlayGame;
            _uiManager.ShowWindow(UIWindowEnum.SPLASH, true);

            Core.Instance.GetService <NetworkManager>().Join_Play(gameId, _playerManager.selectedCar, () =>
            {
                if (!_sPlayerP.IsGameId(gameId))
                {
                    Debug.Log("NEW GAME");
                    _sPlayerP.SafeDataOnPlayClick(_gameManager.GetGameDataByID(gameId));
                    _gameManager.StartGame(gameId);
                }
                else if (_sPlayerP.IsRecord(gameId))
                {
                    Debug.Log("RECORD GAME");
                    _gameManager.ApplyTrack(_sPlayerP.GetTrack(gameId), gameId);
                    _sPlayerP.FillReplayStatistic(gameId);
                    _sPlayerP.FillUserStatistic(gameId);
                }
                else
                {
                    Debug.Log("REPLAY GAME");
                    _gameManager.StartGame(gameId);
                }
            }, (err) =>
            {
                if (err == "timeout")
                {
                    _uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                    _enternetWindow.ShowErrorEnternet();
                    _multiplayerWindow.OnPlay += OnPlayGame;
                }
                else
                {
                    Debug.LogError("OnPlayGame err");
                }
            });
        }