Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            _mouseState    = _mouse.GetState();
            _keyboardState = _keyboard.GetState();

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        public void Update()
        {
            var keyboardState = _keyboard.GetState();

            var pressedKeys         = keyboardState.GetPressedKeys().ToHashSet();
            var previousPressedKeys = _previousKeyboardState.GetPressedKeys().ToHashSet();

            if (KeyUp != null)
            {
                foreach (var key in previousPressedKeys)
                {
                    if (!pressedKeys.Contains(key))
                    {
                        KeyUp.Invoke(this, new KeyEventArgs(key));
                    }
                }
            }

            if (KeyDown != null)
            {
                foreach (var key in pressedKeys)
                {
                    if (!previousPressedKeys.Contains(key))
                    {
                        KeyDown.Invoke(this, new KeyEventArgs(key));
                    }
                }
            }

            _previousKeyboardState = keyboardState;
        }
Ejemplo n.º 3
0
        protected override void Update(GameTime time)
        {
            if (_first)
            {
                // WPF window is not yet loaded when initialize is called, thus SetCursor does not work there, instead call it in the first update
                _mouse.SetCursor(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
                _first = false;
            }
            // every update we can now query the keyboard & mouse for our WpfGame
            var mouseState = _mouse.GetState();

            if (mouseState.X == 0 && mouseState.Y == 0)
            {
                // WPF returns empty mouseposition at startup, until window is at least once rendered. only then will it return proper mouse positions
                // so we deferr updating until we get a valid mousestate
                return;
            }
            var keyboardState = _keyboard.GetState();

            if (!IsActive())
            {
                return;
            }
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                Environment.Exit(0);
            }
            _terrainScene.Update(time, mouseState, keyboardState, (x, y) => _mouse.SetCursor(x, y));
        }
Ejemplo n.º 4
0
        public static void Update()
        {
            lastKeys  = keys;
            lastMouse = mouse;

            keys  = wpfKey.GetState();
            mouse = wpfMouse.GetState();
        }
        protected override void Update(GameTime time)
        {
            // every update we can now query the keyboard & mouse for our WpfGame
            var mouseState    = mouse.GetState();
            var keyboardState = keyboard.GetState();

            particleSystem.Update(time);
        }
Ejemplo n.º 6
0
        public void Update()
        {
            _lastFrameKBState = _currentKBState;
            _lastMouseState   = _currentMouseState;

            _currentKBState    = _keyboard.GetState();
            _currentMouseState = _mouse.GetState();
        }
Ejemplo n.º 7
0
        public void Update(WpfKeyboard keyboard, WpfMouse mouse)
        {
            PreviousKeyboardState = CurrentKeyboardState;
            CurrentKeyboardState  = keyboard.GetState();
            KeyboardStateExtended = new KeyboardStateExtended(CurrentKeyboardState, PreviousKeyboardState);

            PreviousMouseState = CurrentMouseState;
            CurrentMouseState  = mouse.GetState();
            MouseStateExtended = new MouseStateExtended(CurrentMouseState, PreviousMouseState);
        }
Ejemplo n.º 8
0
        protected override void Update(GameTime gameTime)
        {
            _map.ViewBounds = GraphicsDevice.Viewport.Bounds.ToMapRectangle();

            SteuerSoft.Maps.Controls.MonoGame.Material.InputArgs args = new InputArgs();
            args.MouseState    = _mouse.GetState();
            args.KeyboardState = _keyboard.GetState();
            _map.Update(gameTime, args);

            base.Update(gameTime);
        }
Ejemplo n.º 9
0
        protected override void Update(GameTime gameTime)
        {
            // every update we can now query the keyboard & mouse for our WpfGame
            var mouseState    = mouse.GetState();
            var keyboardState = keyboard.GetState();

            if (Playing)
            {
                SpriteEdited.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            base.Update(gameTime);
        }
Ejemplo n.º 10
0
        public override void Update(GameTime gameTime)
        {
            //KeyboardState state = Keyboard.GetState();
            var state = _keyboard.GetState();

            this.RaisePressedEvents(gameTime, state);
            this.RaiseReleasedEvents(state);
            if (this.RepeatPress)
            {
                this.RaiseRepeatEvents(gameTime, state);
            }
            this._previousState = state;
        }
        protected override void Update(GameTime gameTime)
        {
            var previousKeyboardState = _keyboardState;

            _keyboardState = _keyboard.GetState();

            if (_keyboardState.IsKeyDown(Keys.Space) &&
                previousKeyboardState.IsKeyUp(Keys.Space))
            {
                _graphicsDeviceService.PreferMultiSampling = !_graphicsDeviceService.PreferMultiSampling;
                _graphicsDeviceService.ApplyChanges();

                _msaaMessage.Text = GetMsaaMessage();
            }
            base.Update(gameTime);
        }
Ejemplo n.º 12
0
        protected override void Update(GameTime time)
        {
            // every update we can now query the keyboard & mouse for our WpfGame
            _mouseState    = _mouse.GetState();
            _keyboardState = _keyboard.GetState();

            if (KeyPressed(Keys.Q))
            {
                //_renderManager.RenderBoxes();
                GameManager.GetInstance().GetRenderManager().RenderBoxes();
            }

            //_renderManager.Update(time);
            GameManager.GetInstance().Update(time);

            _previousKeyboardState = _keyboardState;
            _previousMouseState    = _mouseState;
        }
        protected override void Update(GameTime time)
        {
            _mouseState    = _mouse.GetState();
            _keyboardState = _keyboard.GetState();

            if (KeyPressed(Keys.F1))
            {
                FocusOnMouseOver = !FocusOnMouseOver;
            }
            if (KeyPressed(Keys.F2))
            {
                _mouse.CaptureMouseWithin = !_mouse.CaptureMouseWithin;
            }
            if (KeyPressed(Keys.Delete))
            {
                // clear message
                EnteredMessage = "";
            }
            else
            {
                var sb = new StringBuilder();
                for (int i = (int)Keys.A; i <= (int)Keys.Z; i++)
                {
                    if (KeyPressed((Keys)i))
                    {
                        // key pressed, add key to queue
                        sb.Append(((char)i));
                    }
                }
                if (KeyPressed(Keys.Space))
                {
                    sb.Append(' ');
                }
                // concat to message
                EnteredMessage += sb.ToString().ToLower();
            }
            _previousKeyboardState = _keyboardState;
            base.Update(time);
        }
Ejemplo n.º 14
0
        public override void Update(GameTime gameTime)
        {
            _input.PreviousKeyboardState = _input.CurrentKeyboardState;
            _input.PreviousMouseState    = _input.CurrentMouseState;
            _input.CurrentKeyboardState  = _keyboard.GetState();
            _input.CurrentMouseState     = _mouse.GetState();

            ViewModel?.LoadContent(Game.Content);
            ViewModel?.Update(gameTime, _input);

            if (_input.IsMousePressed(MouseButton.Left) || _input.IsMouseHeld(MouseButton.Left))
            {
                ViewModel?.DrawPrimaryTile();
            }

            if (_input.IsMousePressed(MouseButton.Right) || _input.IsMouseHeld(MouseButton.Right))
            {
                ViewModel?.DrawSecondaryTile();
            }

            base.Update(gameTime);
        }
Ejemplo n.º 15
0
        protected override void Update(GameTime gameTime)
        {
            var previous = _mouseState;

            _mouseState    = _mouse.GetState();
            _keyboardState = _keyboard.GetState();

            if (_mouseState.LeftButton == ButtonState.Pressed &&
                previous.LeftButton == ButtonState.Released)
            {
                // toggle between 1 and the system value
                if ((_graphicsDeviceService.DpiScalingFactor - 1) <= 0.0001f)
                {
                    _graphicsDeviceService.DpiScalingFactor = _graphicsDeviceService.SystemDpiScalingFactor;
                }
                else
                {
                    _graphicsDeviceService.DpiScalingFactor = 1;
                }
            }

            base.Update(gameTime);
        }
Ejemplo n.º 16
0
 protected override void Update(GameTime time)
 {
     // every update we can now query the keyboard & mouse for our WpfGame
     var mouseState    = _mouse.GetState();
     var keyboardState = _keyboard.GetState();
 }
Ejemplo n.º 17
0
 protected override void Update(GameTime time)
 {
     var mouseState    = _mouse.GetState();
     var keyboardState = _keyboard.GetState();
 }
 public void Reset()
 {
     _currentKeyboardState = _wpfKeyboard.GetState();
     _lastKeyboardState    = _wpfKeyboard.GetState();
 }
Ejemplo n.º 19
0
        protected override void Update(GameTime time)
        {
            var keyboardState = _keyboard.GetState();
            int velocity;

            velocity = keyboardState.IsKeyDown(Keys.LeftShift) ? 10 : 1;
            if (keyboardState.IsKeyDown(Keys.W))
            {
                _y -= velocity;
            }
            if (keyboardState.IsKeyDown(Keys.S))
            {
                _y += velocity;
            }
            if (keyboardState.IsKeyDown(Keys.A))
            {
                _x -= velocity;
            }
            if (keyboardState.IsKeyDown(Keys.D))
            {
                _x += velocity;
            }
            //SCALE = 1 +  / 10000.0f;
            var diff = _mouse.GetState().ScrollWheelValue - _prevScrlVal;

            if (diff > 0)
            {
                SCALE += SCALE * 0.5f;
            }
            else if (diff < 0)
            {
                SCALE -= SCALE * 0.25f;
            }
            _prevScrlVal            = _mouse.GetState().ScrollWheelValue;
            DebugInfo.DebugMessage += $"Spawners: {_spawners.Count}\n";

            int updateVal = (int)MainWindow.Sliders["UpdatePerFrame"].Value;

            if (keyboardState.IsKeyDown(Keys.Space))
            {
                return;
            }

            if (updateVal <= 0)
            {
                if (_counter == 0)
                {
                    for (int j = _spawners.Count - 1; j >= 0; j--)
                    {
                        if (_spawners[j].IsDeleted)
                        {
                            _spawners.RemoveAt(j);
                        }
                        else
                        {
                            _spawners[j].Update();
                        }
                    }
                }
                _counter = (_counter + 1) % (-updateVal + 2);
            }
            else
            {
                for (int i = 0; i < updateVal; i++)
                {
                    for (int j = _spawners.Count - 1; j >= 0; j--)
                    {
                        if (_spawners[j].IsDeleted)
                        {
                            _spawners.RemoveAt(j);
                        }
                        else
                        {
                            _spawners[j].Update();
                        }
                    }
                }
            }

            base.Update(time);
        }
Ejemplo n.º 20
0
        public void Update(GameTime gameTime)
        {
            if (MouseState == null)
            {
                return;
            }

            var mouseState    = MouseState.GetState();
            var keyboardState = KeyboardState.GetState();

            if (!Game.IsActive)
            {
                PrevMouseState = mouseState;
                return;
            }
            if (keyboardState.IsKeyDown(Keys.W))
            {
                Position += Dir * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.S))
            {
                Position -= Dir * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.A))
            {
                Position += Vector3.Cross(Up, Dir) * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.D))
            {
                Position -= Vector3.Cross(Up, Dir) * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.Space))
            {
                Position += Up * Speed;
            }

            // camera speed control

            /*if (mouseState.ScrollWheelValue != PrevScrollWheelValue)
             * {
             *  var diff = mouseState.ScrollWheelValue - PrevScrollWheelValue;
             *  if (diff >= 0)
             *      Speed *= SpeedMod;
             *  else
             *      Speed /= SpeedMod;
             *
             *  PrevScrollWheelValue = mouseState.ScrollWheelValue;
             * }
             *
             * // yaw / x-rotation
             * Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Up,
             *  -MathHelper.PiOver4 / 160 * (mouseState.X - PrevMouseState.X)));
             *
             * // pitch / y-rotation
             * Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Vector3.Cross(Up, Dir),
             *  MathHelper.PiOver4 / 160 * (mouseState.Y - PrevMouseState.Y)));
             *
             * Dir.Normalize();*/

            //SetMouse();

            CreateLookAt();

            //Console.WriteLine("Camera pos: " + ParticleViewer.Instance.Render.Camera.Position);
            //Console.WriteLine("Camera dir: " + ParticleViewer.Instance.Render.Camera.Dir);
        }
Ejemplo n.º 21
0
 public void Update(WpfKeyboard keyboard)
 {
     PreviousKeyboardState = CurrentKeyboardState;
     CurrentKeyboardState  = keyboard.GetState();
     KeyboardStateExtended = new KeyboardStateExtended(CurrentKeyboardState, PreviousKeyboardState);
 }
Ejemplo n.º 22
0
        public void Update(GameTime gameTime)
        {
            if (Mouse == null)
            {
                return;
            }

            var mouseState    = Mouse.GetState();
            var keyboardState = Keyboard.GetState();

            if (!Game.IsActive)
            {
                PrevMouseState = mouseState;
                return;
            }
            if (keyboardState.IsKeyDown(Keys.W))
            {
                Position += Dir * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.S))
            {
                Position -= Dir * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.A))
            {
                Position += Vector3.Cross(Up, Dir) * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.D))
            {
                Position -= Vector3.Cross(Up, Dir) * Speed;
            }
            if (keyboardState.IsKeyDown(Keys.Space))
            {
                Position += Up * Speed;
            }

            // camera speed control
            if (mouseState.ScrollWheelValue != PrevScrollWheelValue)
            {
                var diff = mouseState.ScrollWheelValue - PrevScrollWheelValue;
                if (diff >= 0)
                {
                    Speed *= SpeedMod;
                }
                else
                {
                    Speed /= SpeedMod;
                }

                PrevScrollWheelValue = mouseState.ScrollWheelValue;
            }

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                if (PrevMouseState.RightButton == ButtonState.Pressed)
                {
                    // yaw / x-rotation
                    Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Up,
                                                                            -MathHelper.PiOver4 / 160 * (mouseState.X - centerX)));

                    // pitch / y-rotation
                    Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Vector3.Cross(Up, Dir),
                                                                            MathHelper.PiOver4 / 160 * (mouseState.Y - centerY)));
                }
                else
                {
                    System.Windows.Input.Mouse.OverrideCursor = Cursors.None;
                }
                // there is a delay here, so Mouse.GetState() won't be immediately affected
                Mouse.SetCursor(centerX, centerY);
            }
            else if (PrevMouseState.RightButton == ButtonState.Pressed)
            {
                System.Windows.Input.Mouse.OverrideCursor = Cursors.Arrow;
            }

            PrevMouseState = mouseState;

            Dir.Normalize();

            CreateLookAt();

            //Console.WriteLine("Camera pos: " + GameView.Instance.Render.Camera.Position);
            //Console.WriteLine("Camera dir: " + GameView.Instance.Render.Camera.Dir);
        }
Ejemplo n.º 23
0
 public KeyboardState GetState()
 {
     return(WpfKeyboard == null?Microsoft.Xna.Framework.Input.Keyboard.GetState() : WpfKeyboard.GetState());
 }