Esempio n. 1
0
        private async void ReconnectButtonOnClickHandler()
        {
            try
            {
                ConnectionPopup connectionPopup = _uiManager.GetPopup <ConnectionPopup>();

                Func <Task> connectFunc = async() =>
                {
                    bool success = true;
                    try
                    {
                        await _backendDataControlMediator.LoginAndLoadData();
                    }
                    catch (Exception)
                    {
                        // HACK: ignore to allow offline mode
                    }

                    if (!_backendFacade.IsConnected)
                    {
                        success = false;
                    }

                    if (success)
                    {
                        connectionPopup.Hide();
                    }
                    else
                    {
                        connectionPopup.ShowFailedOnMenu();
                    }
                };
                _uiManager.DrawPopup <ConnectionPopup>();
                connectionPopup.ConnectFunc = connectFunc;
                await connectionPopup.ExecuteConnection();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                OpenAlertDialog(
                    $"Reconnect failed. Please check your Internet connection.\n\nAdditional info: {e.GetType().Name} [{e.Message}]");
            }
        }
Esempio n. 2
0
        public async void Update()
        {
            if (_selfPage == null)
            {
                return;
            }

            if (!_selfPage.activeInHierarchy ||
                GameClient.Get <IAppStateManager>().AppState != Enumerators.AppState.APP_INIT)
            {
                return;
            }

            if (!_isLoaded)
            {
                _percentage          += 1f;
                _loaderBar.fillAmount = Mathf.Clamp(_percentage / 100f, 0.03f, 1f);
                if (_percentage >= 100)
                {
                    _isLoaded = true;
                    _progressBar.gameObject.SetActive(false);
                    _pressAnyText.gameObject.SetActive(true);
                }
            }
            else
            {
                if (!Input.anyKey)
                {
                    return;
                }

                if (!_pressAnyText.gameObject.activeSelf)
                {
                    return;
                }

                _pressAnyText.gameObject.SetActive(false);

                if (_backendDataControlMediator.LoadUserDataModel() &&
                    _backendDataControlMediator.UserDataModel.IsValid)
                {
                    ConnectionPopup connectionPopup = _uiManager.GetPopup <ConnectionPopup>();

                    Func <Task> connectFunc = async() =>
                    {
                        bool success = true;
                        try
                        {
                            await _backendDataControlMediator.LoginAndLoadData();
                        }
                        catch (GameVersionMismatchException e)
                        {
                            success = false;
                            _uiManager.DrawPopup <LoginPopup>();
                            _uiManager.GetPopup <LoginPopup>().Show(e);
                        }
                        catch (Exception e)
                        {
                            // HACK: ignore to allow offline mode
                            Debug.LogWarning(e);
                        }

                        connectionPopup.Hide();

                        if (success)
                        {
                            GameClient.Get <IAppStateManager>().ChangeAppState(Enumerators.AppState.MAIN_MENU);
                        }
                    };
                    _uiManager.DrawPopup <ConnectionPopup>();
                    connectionPopup.ConnectFunc = connectFunc;
                    await connectionPopup.ExecuteConnection();
                }
                else
                {
                    _uiManager.DrawPopup <LoginPopup>();
                }
            }
        }