Example #1
0
        private void BuyInNetwork(int id)
        {
            _splashScreen.ShowLoadingPanel();
            int accountType = _playerManager.accountType;

            _networkManager.BuyInScore(id, (msg) =>
            {
                _splashScreen.HideLoadingPanel();
                if (msg == 1)
                {
                    if (id > 6)
                    {
                        _header.GoldChanged();
                        _header.JewelChanged();
                        _statisticPanel.Init(); _header.UpdateAccoutSprite(() =>
                        {
                            StartCoroutine(ShowImg(Thank, () => { BlockPanel.SetActive(false); }));
                        });
                    }
                    else
                    {
                        StartCoroutine(ShowImg(Thank, () => { BlockPanel.SetActive(false); }));
                        _header.GoldChanged();
                        _header.JewelChanged();
                    }
                }
            }, (err) => {
                if (err == "timeout")
                {
                    BlockPanel.SetActive(false);
                    _splashScreen.HideLoadingPanel();
                    _enternetWindow.ShowErrorEnternet();
                }
                else
                {
                    _splashScreen.HideLoadingPanel();
                    BlockPanel.SetActive(false);
                    Debug.LogError("BuyInNetwork err");
                }
            });
        }
Example #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");
                }
            });
        }
Example #3
0
        // used on button !
        public void PlayGame()
        {
            // pre-condition
            Assert.IsTrue(_gameID != "");

            Core.Instance.GetService <NetworkManager>().Join_Play(_gameID, Core.Instance.GetService <PlayerManager>().selectedCar, () =>
            {
                _safePlayerPrefs.SafeDataOnPlayClick(_gameData);
                _gameManager.StartGame(_gameID);
            },
                                                                  (err) =>
            {
                if (err == "timeout")
                {
                    _uiManager.ShowWindow(UIWindowEnum.SPLASH, false);
                    _enternetWindow.ShowErrorEnternet();
                }
                else
                {
                    Debug.LogError("PlayGame err");
                }
            });
        }
Example #4
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");
        }
Example #5
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();
                }

                                   );
            }
        }