Exemplo n.º 1
0
        public override void HandleInput(InputState inputState)
        {
            base.HandleInput(inputState);

            if (inputState.MenuEnter || inputState.MenuCancel)
            {
                Stop();
            }
        }
Exemplo n.º 2
0
 public override void HandleInput(InputState input)
 {
     // Not much to handle for a textblock
 }
Exemplo n.º 3
0
 public override void HandleInput(InputState input)
 {
 }
Exemplo n.º 4
0
        public override void HandleInput(InputState inputState)
        {
            if (!_isEditing)
            {
                base.HandleInput(inputState);
            }
            else
            {
                if (inputState.MenuCancel)
                {
                    _isEditing = false;
                }
                if (inputState.MenuRight)
                {
                    _selectedSegment.X++;
                }
                if (inputState.MenuLeft)
                {
                    _selectedSegment.X--;
                }
                if (inputState.MenuUp)
                {
                    _selectedSegment.Y++;
                }
                if (inputState.MenuDown)
                {
                    _selectedSegment.Y--;
                }

                if (inputState.MenuEnter)
                {
                    showBindSegmentScreen(getSelectedSegment(), false);
                }

                if (_selectedSegment.X > 19)
                {
                    _selectedSegment.X = 0;
                }
                if (_selectedSegment.Y > 5)
                {
                    _selectedSegment.Y = 1;
                }
                if (_selectedSegment.X < 0)
                {
                    _selectedSegment.X = 19;
                }
                if (_selectedSegment.Y < 1)
                {
                    _selectedSegment.Y = 5;
                }
            }

            var boardRectangle = new Rectangle((int) (_boardPosition.X - _boardScale*_mapTexture.Width*0.5 - 20.0f),
                (int) (_boardPosition.Y - _boardScale*_mapTexture.Height*0.5),
                (int) (_mapTexture.Width*_boardScale),
                (int) (_mapTexture.Height*_boardScale));

            _drawCoords = false;
            _mouseOver = null;
            _mouseVector = new Vector2(inputState.CurrentMouseState.X, inputState.CurrentMouseState.Y);

            if (boardRectangle.Contains(inputState.CurrentMouseState.X, inputState.CurrentMouseState.Y))
            {
                var dx = inputState.CurrentMouseState.X -
                         (int) (_boardPosition.X - _boardScale*_mapTexture.Width*0.5f - 20.0f);
                var dy = inputState.CurrentMouseState.Y - (int) (_boardPosition.Y - _boardScale*_mapTexture.Height*0.5f);

                var rotation = (float) Math.Atan2(dy, dx);

                var tempVector = _boardPosition - _mouseVector;
                _distance = tempVector.Length();
                tempVector.Normalize();

                var segmentVector = Vector2.UnitY;
                var rotationMatrix = Matrix.CreateRotationZ(MathHelper.ToRadians(18));

                if (_distance < 350.0f*_boardScale) //Inside dartboard
                {
                    _drawCoords = true;

                    if (_distance < 15.0f*_boardScale) //Double bull
                    {
                        _mouseOver = new IntPair(25, 2);
                    }
                    else if (_distance < 40.0f*_boardScale) //Single bull
                    {
                        _mouseOver = new IntPair(25, 1);
                    }
                    else
                    {
                        for (var i = 0; i < 20; i++)
                        {
                            var angle = (float) Math.Acos(Vector2.Dot(segmentVector, tempVector));

                            var tripleRadius = 190.0f*_boardScale;
                            var doubleRadius = 320.0f*_boardScale;

                            if (Math.Abs(angle) < MathHelper.ToRadians(9.0f))
                            {
                                _mouseOver = new IntPair(_segmentOrder[i], 0);

                                if (_distance > tripleRadius && _distance < tripleRadius + 30.0f*_boardScale)
                                    // Triple
                                {
                                    _mouseOver.Y = 3;
                                }
                                else if (_distance > doubleRadius) //Double
                                {
                                    _mouseOver.Y = 2;
                                }
                                else
                                {
                                    _mouseOver.Y = 1;
                                }

                                break;
                            }

                            segmentVector = Vector2.Transform(segmentVector, rotationMatrix);
                        }
                    }

                    if (inputState.MouseClick)
                    {
                        if (_mouseOver != null)
                        {
                            showBindSegmentScreen(_mouseOver, false);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Temporary(or not? :D) solution for handling mouse input
        /// </summary>
        /// <param name="inputState"></param>
        private void handleMouseInput(InputState inputState)
        {
            var height = 0;

            for (var i = 0; i < StackPanel.Items.Count; i++)
            {
                if (StackPanel.Items[i] == MenuItems)
                {
                    for (var j = 0; j < MenuItems.Items.Count; j++)
                    {
                        var menuItemBoundingBox = new Rectangle((int) (MenuPosition.X*XnaDartsGame.Viewport.Width),
                            (int) (MenuPosition.Y*XnaDartsGame.Viewport.Height + height), MenuItems.Items[j].Width,
                            MenuItems.Items[j].Height);
                        if (menuItemBoundingBox.Contains(inputState.CurrentMouseState.X, inputState.CurrentMouseState.Y))
                        {
                            _selectedEntry = j;

                            if (inputState.MouseClick)
                            {
                                ((MenuEntry) MenuItems.Items[j]).Select();
                            }
                            else if (inputState.MouseRightClick)
                            {
                                ((MenuEntry) MenuItems.Items[j]).Cancel();
                            }

                            break;
                        }
                        height += MenuItems.Items[j].Height;
                    }
                    break;
                }
                height += StackPanel.Items[i].Height;
            }
        }
Exemplo n.º 6
0
        public override void HandleInput(InputState inputState)
        {
            if (inputState.MenuCancel)
            {
                pause();
            }

            if (inputState.IsKeyPressed(Keys.F6))
            {
                _showDartboard = !_showDartboard;
            }

            if (_showDartboard)
            {
                _dartboard.HandleInput(inputState);
            }

            if (inputState.IsKeyPressed(Keys.Space))
            {
                ForcePlayerChange();
            }
        }
Exemplo n.º 7
0
        public override void HandleInput(InputState inputState)
        {
            var oldSelectedEntry = _selectedEntry;

            handleKeyboardInput(inputState);
            handleMouseInput(inputState);

            if (oldSelectedEntry != _selectedEntry)
            {
                ((MenuEntry) MenuItems.Items[oldSelectedEntry]).Color = XnaDartsGame.Options.MenuItemForeground;
                ((MenuEntry) MenuItems.Items[_selectedEntry]).Color = XnaDartsGame.Options.SelectedMenuItemForeground;
                XnaDartsGame.SoundManager.PlaySound(SoundCue.MenuSelect);
            }
        }
Exemplo n.º 8
0
        private void handleKeyboardInput(InputState inputState)
        {
            var selectedMenuEntry = MenuItems.Items[_selectedEntry];
            selectedMenuEntry.HandleInput(inputState);

            if (inputState.MenuDown)
            {
                _selectedEntry++;
            }
            if (inputState.MenuUp)
            {
                _selectedEntry--;
            }

            if (_selectedEntry > MenuItems.Items.Count - 1)
            {
                _selectedEntry = 0;
            }
            if (_selectedEntry < 0)
            {
                _selectedEntry = MenuItems.Items.Count - 1;
            }

            if (inputState.MenuCancel)
            {
                XnaDartsGame.SoundManager.PlaySound(SoundCue.MenuBack);
                CancelScreen();
            }
        }
Exemplo n.º 9
0
 public override void HandleInput(InputState inputState)
 {
     if (inputState.MenuCancel || inputState.MenuEnter)
     {
         TimedOut();
     }
 }
Exemplo n.º 10
0
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);

            handleKeyboardInput(input);
        }
Exemplo n.º 11
0
        private void handleKeyboardInput(InputState input)
        {
            if (input.MenuLeft)
            {
                MenuLeft();
            }

            if (input.MenuRight)
            {
                MenuRight();
            }

            if (input.MenuEnter)
            {
                Select();
            }

            if (input.MenuBack)
            {
                Cancel();
            }
        }
Exemplo n.º 12
0
 public abstract void HandleInput(InputState input);
Exemplo n.º 13
0
 public virtual void HandleInput(InputState inputState)
 {
 }