示例#1
0
        public void Disable()
        {
            Debug.Log("Disable GAME_ASYNC");
            _gameWindow._objBackground.SetActive(true);
            _uiManager.ShowWindow(UIWindowEnum.SPLASH, true);

            _gameWindow.Hide();
            _pauseWindow.Hide();

            // -------------------------------------------
            //

            EventManager._init.Game.MenuButton.Resume -= Resume;
            _pauseWindow.OnMenuClick -= Menu;
            // -------------------------------------------

            _gameManager.Destroy();
        }
示例#2
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");
                }
            });
        }
示例#3
0
        public void EndTutorial()
        {
            _chooseCarWindow.ShowTutorialOnBuyCar  -= ActionCarBuy;
            _chooseCarWindow.ShowTutorialCarUpdate -= ActionUpdateBuy;

            HideAllTextAndButton();

            _uiManager.ShowWindow(UIWindowEnum.SPLASH, true);

            _networkManager.EndTutorial(
                endTutorialSucces, endTutorialError
                );
        }
示例#4
0
        // I_STATES

        public void Enable()
        {
            _gameManager = Core.Instance.GetService <GameManager>();
            Assert.AreNotEqual(null, _gameManager);

            _statesManager = Core.Instance.GetService <StatesManager>();
            Assert.AreNotEqual(null, _statesManager);

            //
            _uiManager = Core.Instance.GetService <UIManager>();
            Assert.AreNotEqual(null, _uiManager);

            _mainScreenStateManager = _uiManager.Get_MainScreenStateManager();
            Assert.AreNotEqual(null, _mainScreenStateManager);

            _gameWindow = _uiManager.GetWindow(UIWindowEnum.GAMEWINDOW_ASYNC) as GameWindowAsyncMultiplayer;
            Assert.AreNotEqual(null, _gameWindow);

            _pauseWindow = _uiManager.GetWindow(UIWindowEnum.PAUSE_ASYNC) as PauseWindow;
            Assert.AreNotEqual(null, _pauseWindow);

            _audioService = Core.Instance.GetService <AudioService>();
            Assert.AreNotEqual(null, _audioService);
            //

            Debug.Log("Enable GAME_ASYNC");

            EventManager._init.Game.MenuButton.Resume += Resume;
            _pauseWindow.OnMenuClick += Menu;

            _gameManager.CreateGameHandler();

            //

            Assert.AreNotEqual(null, _gameWindow._objBackground);

            _gameWindow._objBackground.SetActive(false);

            // -------------------------------------------
            //

            // -------------------------------------------

            //
            _uiManager.ShowWindow(UIWindowEnum.SPLASH, true);
            _mainScreenStateManager.SwitchState(MainScreenStatesEnum.GAME_ASYNC);
        }
示例#5
0
        public void Enable()
        {
            Debug.Log("MAIN_MULTIPLAYER_WINDOW  Enable");
            _audioService = Core.Instance.GetService <AudioService>();

            _uiManager = Core.Instance.GetService <UIManager>();
            _header    = _uiManager.GetWindow(UIWindowEnum.HEADER) as Header;
            _header.Show();
            _sPlayerP = Core.Instance.GetService <SafePlayerPrefs>();

            _mainScreenStateManager = _uiManager.Get_MainScreenStateManager();

            _eventSecvice = Core.Instance.GetService <EventService>();

            _notificationWindow = _uiManager.NotificationWindow;

            _enternetWindow = _uiManager.GetWindow(UIWindowEnum.IS_ENTERNET) as EnternetWindow;

            if (_core == null)
            {
                _core = Core.Instance;
            }
            _audioService.StartMenuMusic();

            _gameManager   = _core.GetService <GameManager>();
            _playerManager = _core.GetService <PlayerManager>();

            _multiplayerWindow = (MultiplayerWindow)_uiManager.GetWindow(UIWindowEnum.MAIN_MULTIPLAYER);
            //chooseCarWindow = (ChooseCarWindow)_uim.GetWindow(UIWindowEnum.CHOOSECAR);

            _multiplayerWindow.OnPlay       += OnPlayGame;
            _multiplayerWindow.OnRandomGame += OnRandomGame;

            //
            _gameManager.OnGamesUpdated  += OnUpdateGamesList;
            _gameManager.OnFriendsUpdate += OnUpdateFriendList;


            if (_eventSecvice.IsEventComplete())
            {
                Debug.Log("IsEventComplete");
                _uiManager.ShowWindow(UIWindowEnum.SPLASH, true);
                _eventSecvice.ShowCompleteAnim(() => {
                    if (_playerManager.IsDone != -1)
                    {
                        _gameManager.LoadGames(() => { _notificationWindow.ShowYouOpenTrack(_playerManager.IsDone); _playerManager.IsDone = -1; });
                    }
                    else
                    {
                        _gameManager.LoadGames();
                    }
                });
            }
            else
            {
                if (_playerManager.IsDone != -1)
                {
                    _gameManager.LoadGames(() => { _notificationWindow.ShowYouOpenTrack(_playerManager.IsDone); _playerManager.IsDone = -1; });
                }
                else
                {
                    _gameManager.LoadGames();
                }
            }
        }
示例#6
0
        public void LoadGames(Action OnComplete = null)
        {
            Debug.Log("ButtAsyncOn" + ButtAsyncOn);
            if (!ButtAsyncOn)
            {
                _splashScreen.ShowLoadingPanel();
                Debug.Log("LoadGames");
                ButtAsyncOn = true;
                _networkManager.LoadGames(
                    (data) =>
                {
                    Debug.Log("LoadGames ok");
                    Games.Clear();
                    Games = data;
                    _uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                    if (OnGamesUpdated != null)
                    {
                        OnGamesUpdated(Games);
                        if (_playerManager.IsDone != -1)
                        {
                            OnComplete();
                        }

                        //_uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                    }
                    ButtAsyncOn = false;
                },
                    (err) => {
                    if (err == "timeout")
                    {
                        ButtAsyncOn = false;
                        Debug.Log("LoadGames err " + _multiplayerWindow.canvaseGroup.alpha + " ");

                        _uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                        //_uiManager.
                        if (_multiplayerWindow.canvaseGroup.alpha != 1)
                        {
                            Debug.Log("_multiplayerWindow.canvaseGroup.alpha != 1 " + _multiplayerWindow.canvaseGroup.alpha);
                            _uiManager.ShowWindow(UIWindowEnum.MAIN_MULTIPLAYER, true);
                        }

                        _enternetWindow.ShowErrorEnternet();
                    }
                    else
                    {
                        Debug.LogError("LoadGames err");
                        ButtAsyncOn = false;
                    }
                },
                    (ErrorLoad) => {
                    if (ErrorLoad == "timeout")
                    {
                        ButtAsyncOn = false;
                        Debug.Log("LoadGames err " + _multiplayerWindow.canvaseGroup.alpha + " ");

                        _uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                        _enternetWindow.ShowErrorEnternet();
                    }
                    else
                    {
                        Debug.LogError("LoadGames err");
                        ButtAsyncOn = false;
                    }
                });
                //Debug.Log("posle");
            }
            //Debug.Log("posle");
        }
示例#7
0
        public void Enable()
        {
            //Get UI, cache ref
            if (_core == null)
            {
                _core = Core.Instance;
                _nm   = _core.GetService <NetworkManager>();


                _pm                 = _core.GetService <PlayerManager>();
                _uim                = _core.GetService <UIManager>();
                _enternetWindow     = _uim.GetWindow(UIWindowEnum.IS_ENTERNET) as EnternetWindow;
                authificationWindow = (AuthentificationWindow)_uim.GetWindow(UIWindowEnum.AUTHENTIFICATION);
            }


            //_pm.OnUserLoaded += OnUserLoaded;

            authificationWindow.OnLogin      += OnLoginSend;
            authificationWindow.OnRegistered += OnRegisterSend;

            var savedPlayerName = PlayerPrefs.GetString(PPKeys.name);
            var savedPlayerPass = PlayerPrefs.GetString(PPKeys.pass);

            if (string.IsNullOrEmpty(savedPlayerName) || string.IsNullOrEmpty(savedPlayerPass))
            {
                PlayerPrefs.SetString(PPKeys.name, "");         // ???????
                PlayerPrefs.SetString(PPKeys.pass, "");
                authificationWindow.Show();
                Debug.Log("Enable Auth");
            }
            else
            {
                _uim.ShowWindow(UIWindowEnum.SPLASH, true);
                _nm.Authentication(savedPlayerName, savedPlayerPass,
                                   (obj, error) =>
                {
                    //Core.Instance.GetService<SafePlayerPrefs>().DeleteDataForLogOut();

                    if (error != "timeout")
                    {
                        PlayerPrefs.SetString(PPKeys.name, "");        // ???????
                        PlayerPrefs.SetString(PPKeys.pass, "");        // ???????
                        Core.Instance.GetService <StatesManager>().SwitchState(StatesEnum.Auth);
                    }
                    else
                    {
                        _enternetWindow.ShowErrorEnternet(() => { Core.Instance.GetService <StatesManager>().SwitchState(StatesEnum.Auth); }, "Try Again");
                        authificationWindow.Show();
                    }

                    Debug.Log("Enable Auth");

                    _uim.ShowWindow(UIWindowEnum.SPLASH, false);
                },
                                   (obj) =>
                {
                    GoToNextState();
                }

                                   );
            }
        }