Ejemplo n.º 1
0
        /// <summary>
        /// Provides keyboard interaction for the UI.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            e.Handled = true;
            switch (e.Key)
            {
            case Key.Escape:
                var menu = new InGameMenuWindow(_game);
                Opacity = 0.5;
                menu.ShowDialog();
                Opacity = 1;
                break;

            case Key.Left:
                if (_gameControl.CanMoveVisibleMapLeft())
                {
                    _gameControl.MoveVisibleMapLeft();
                }
                break;

            case Key.Right:

                if (_gameControl.CanMoveVisibleMapRight())
                {
                    _gameControl.MoveVisibleMapRight();
                }
                break;

            case Key.Up:
                if (_gameControl.CanMoveVisibleMapUp())
                {
                    _gameControl.MoveVisibleMapUp();
                }
                break;

            case Key.Down:
                if (_gameControl.CanMoveVisibleMapDown())
                {
                    _gameControl.MoveVisibleMapDown();
                }
                break;

            case Key.Space:
                _gameControl.MoveVisibleMapToSelectedCase();
                break;

            default:
                e.Handled = false;
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Provides keyboard interaction for the UI.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            e.Handled = true;
            switch (e.Key)
            {
                case Key.Escape:
                    var menu = new InGameMenuWindow(_game);
                    Opacity = 0.5;
                    menu.ShowDialog();
                    Opacity = 1;
                    break;
                case Key.Left:
                    if (_gameControl.CanMoveVisibleMapLeft())
                    {
                        _gameControl.MoveVisibleMapLeft();
                    }
                    break;
                case Key.Right:

                    if (_gameControl.CanMoveVisibleMapRight())
                    {
                        _gameControl.MoveVisibleMapRight();
                    }
                    break;
                case Key.Up:
                    if (_gameControl.CanMoveVisibleMapUp())
                    {
                        _gameControl.MoveVisibleMapUp();
                    }
                    break;
                case Key.Down:
                    if (_gameControl.CanMoveVisibleMapDown())
                    {
                        _gameControl.MoveVisibleMapDown();
                    }
                    break;
                case Key.Space:
                    _gameControl.MoveVisibleMapToSelectedCase();
                    break;
                default:
                    e.Handled = false;
                    break;
            }
        }