Пример #1
0
        public void ChangeSelection(bool up)
        {
            int selectionCount = Enum.GetNames(typeof(PauseSelection)).Length;
            int selectionInt   = (int)pauseSelection;

            if (up)
            {
                pauseSelection = (PauseSelection)(((selectionInt - 1) + selectionCount) % selectionCount);
            }
            else
            {
                pauseSelection = (PauseSelection)(((selectionInt + 1) + selectionCount) % selectionCount);
            }

            _moveSound.Play();
        }
Пример #2
0
        public override void Init(GameData data)
        {
            // Initialize Selection
            pauseSelection = PauseSelection.Continue;

            // Initialize Text
            _pausedText            = new Text("PAUSED", data.Asset.GameFont, 50);
            _pausedText.Position   = new Vector2f((Constants.WindowWidth / 2) - (_pausedText.GetGlobalBounds().Width / 2), Constants.WindowHeight / 10);
            _continueText          = new Text("Continue", data.Asset.GameFont);
            _continueText.Position = new Vector2f((Constants.WindowWidth / 2) - (_continueText.GetGlobalBounds().Width / 2), (Constants.WindowHeight / 2) - 50);
            _restartText           = new Text("Restart", data.Asset.GameFont);
            _restartText.Position  = new Vector2f((Constants.WindowWidth / 2) - (_restartText.GetGlobalBounds().Width / 2), (Constants.WindowHeight / 2) + 50);
            _quitText          = new Text("Quit", data.Asset.GameFont);
            _quitText.Position = new Vector2f((Constants.WindowWidth / 2) - (_quitText.GetGlobalBounds().Width / 2), (Constants.WindowHeight / 2) + 150);
            _moveSound         = new Sound(data.Asset.MenuMoveSound);
            _selectSound       = new Sound(data.Asset.MenuSelectSound);
        }
Пример #3
0
        public override void HandleInput(GameData data, SFML.Window.KeyEventArgs e)
        {
            switch (e.Code)
            {
            case SFML.Window.Keyboard.Key.Up:
                ChangeSelection(true);
                break;

            case SFML.Window.Keyboard.Key.Down:
                ChangeSelection(false);
                break;

            case SFML.Window.Keyboard.Key.Return:
                EnterSelection(data);
                break;

            case SFML.Window.Keyboard.Key.Escape:
                pauseSelection = PauseSelection.Continue;
                EnterSelection(data);
                break;
            }
        }