Esempio n. 1
0
        public void SetLoginState(LoginState state)
        {
            this.ClientLoginState = state;

            switch (state)
            {
            case LoginState.NotLoggedInOrLoginFailed:
            {
                _loginAttemptCount++;

                Action closeAppAction = null;
                if (_loginAttemptCount >= 3)
                {
                    closeAppAction = () => { MainGameHandler.CloseApplication(); }
                }
                ;

                MainGameHandler.ShowMessageBox($"Failed to log in ({_loginAttemptCount}/3)", "Login failed", closeAppAction);
            }
            break;

            case LoginState.Logged:
            {
                _loginAttemptCount = 0;
                Action changeSceneAction = () => { MainGameHandler.ChangeScene(MainGameHandler.SceneType.CharLobby); };
                MainGameHandler.ShowMessageBox($"You have successfully logged in!", "Login success", changeSceneAction);
            }
            break;

            case LoginState.WaitingForResponse:
                //Debug.Log("Login - waiting for response");
                break;
            }
        }
        public bool Execute()
        {
            bool executed = false;

            try
            {
                string jsonString = _rawText.Substring(_keyWord.Length);
                CharacterPositionBasicDetails charPosDetails = JsonConvert.DeserializeObject <CharacterPositionBasicDetails>(jsonString);

                _gameStateDetails.CharId       = charPosDetails.CharId;
                _gameStateDetails.WmId         = charPosDetails.WmId;
                _gameStateDetails.MapWidth     = charPosDetails.MapWidth;
                _gameStateDetails.MapHeight    = charPosDetails.MapHeight;
                _gameStateDetails.LocalBound   = PointConverter.Point3ToVector(charPosDetails.LocalBound);
                _gameStateDetails.IsOnWorldMap = charPosDetails.IsOnWorldMap;
                _gameStateDetails.Position     = PointConverter.Point3ToVector(charPosDetails.Position);

                //_gameStateDetails.LogCurrentState(); //for testing

                if (charPosDetails.IsOnWorldMap)
                {
                    MainGameHandler.ChangeScene(MainGameHandler.SceneType.WorldMap);
                }
                else
                {
                    MainGameHandler.ChangeScene(MainGameHandler.SceneType.LocalPlace);
                }

                executed = true;
            }
            catch (Exception exception)
            {
                _chat.UpdateLog($"Cannot execute char. basic details command: {exception.Message}");
            }

            return(executed);
        }
Esempio n. 3
0
    void Update()
    {
        if (_enabled)
        {
            _timer += Time.deltaTime;
            float tValue   = 0;
            float dividend = 0;
            float divider  = 0;

            if
            (
                _timer > _blackScreenTime &&
                _timer <= (_blackScreenTime + (_fadingAnimationTime / 2))
            )
            {
                dividend = _timer - _blackScreenTime;
                divider  = _fadingAnimationTime / 2;

                if (divider == 0)
                {
                    tValue = 0;
                }
                else
                {
                    tValue = dividend / divider;
                }

                SetAlphaOfElements(tValue);
            }
            else
            if
            (
                _timer > (_blackScreenTime + (_fadingAnimationTime / 2)) &&
                _timer <= (_blackScreenTime + _fadingAnimationTime)
            )
            {
                dividend = _timer - (_blackScreenTime + (_fadingAnimationTime / 2));
                divider  = _fadingAnimationTime / 2;

                if (divider == 0)
                {
                    tValue = 0;
                }
                else
                {
                    tValue = 1 - (dividend / divider);
                }

                SetAlphaOfElements(tValue);
            }
            else
            if (_timer > (_blackScreenTime + _fadingAnimationTime))
            {
                SetAlphaOfElements(0);
            }

            if (_timer > ((_blackScreenTime * 2) + _fadingAnimationTime))
            {
                enabled = false;
                MainGameHandler.ChangeScene(MainGameHandler.SceneType.Login);
            }
        }
    }