예제 #1
0
        public void Update()
        {
            if (KeyboardManager.Instance.IsKeyJustPressed(Keys.Escape))
            {
                _pauseView.IsActive = true;
            }

            if (_pauseView.IsActive)
            {
                _pauseView.Update();
                return;
            }

            if (_walkSfxTimeout > 0)
            {
                _walkSfxTimeout--;
            }
            else if (IsWalking)
            {
                Sfx.PlayStepSound();
                _walkSfxTimeout = 10;
            }

            _levelProceedBlockEffect.Update();

            if (_screens[_currentlySelectedScreen].IsCompleted)
            {
                _creditsWidget.IsRunning = true;
            }

            if (KeyboardManager.Instance.IsKeyJustPressed(Keys.Left))
            {
                Logger.Input("Switching screen to the left");
                _currentlySelectedScreen = Math.Max(0, _currentlySelectedScreen - 1);
            }
            else if (KeyboardManager.Instance.IsKeyJustPressed(Keys.Right))
            {
                Logger.Input("Switching screen to the right");
                if (_screens[_currentlySelectedScreen].IsCompleted)
                {
                    _currentlySelectedScreen = Math.Min(_screens.Count - 1, _currentlySelectedScreen + 1);
                }
                else
                {
                    _levelProceedBlockEffect.Start();
                }
            }

            _currentScreenRenderOffset =
                (float)MathUtils.ApproachFactor(_currentScreenRenderOffset, _currentlySelectedScreen, 0.3, 0.001, 0.1);

            foreach (var ingameScreen in _screens)
            {
                ingameScreen.Update(RenderOffset, true);
            }

            _controlsWidget.Update();
            _creditsWidget.Update();
            SubtitleWidget.Update();
            _controlsWidget.IsHiding = _controlsWidget.IsHiding || _currentlySelectedScreen > 1;
        }