예제 #1
0
 /// <summary>
 /// The same as Update() except only active screens get called.
 /// </summary>
 /// <param name="gameTime">Current GameTime</param>
 /// <param name="input">Input Object to access Mouse and Keyboard</param>
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     foreach (IGuiItem menuEntry in MenuEntries)
     {
         menuEntry.HandleInput(input);
     }
 }
예제 #2
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     foreach (IGuiItem panelEntry in PanelEntries)
     {
         panelEntry.HandleInput(input);
     }
 }
예제 #3
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     base.HandleInput(gameTime, input);
     UpdateCamera(input);
     Map.ForEachActiveEntity((entity) =>
     {
         entity.Update(gameTime, input);
     });
 }
예제 #4
0
        public override void Update(GameTime gameTime, InputState inputState)
        {
            base.Update(gameTime, inputState);

            if (inputState == null || inputState.KeyboardState == null)
            {
                return;
            }

            UpdateInput(gameTime, inputState);
        }
예제 #5
0
        private void UpdateCamera(InputState input)
        {
            var keyBoardState = input.KeyboardState;
            //Rotate Cube along its Up Vector
            if (keyBoardState.IsKeyDown(Keys.X))
            {
                worldMatrix = Matrix.CreateFromAxisAngle(Vector3.Up, .02f) * worldMatrix;
            }
            if (keyBoardState.IsKeyDown(Keys.Z))
            {
                worldMatrix = Matrix.CreateFromAxisAngle(Vector3.Up, -.02f) * worldMatrix;
            }

            //Move Cube Forward, Back, Left, and Right
            if (keyBoardState.IsKeyDown(Keys.Up))
            {
                worldMatrix *= Matrix.CreateTranslation(worldMatrix.Forward);
            }
            if (keyBoardState.IsKeyDown(Keys.Down))
            {
                worldMatrix *= Matrix.CreateTranslation(worldMatrix.Backward);
            }
            if (keyBoardState.IsKeyDown(Keys.Left))
            {
                worldMatrix *= Matrix.CreateTranslation(-worldMatrix.Right);
            }
            if (keyBoardState.IsKeyDown(Keys.Right))
            {
                worldMatrix *= Matrix.CreateTranslation(worldMatrix.Right);
            }

            Camera.Update(worldMatrix);
        }
예제 #6
0
        public void HandleInput(InputState input)
        {
            var mousePosition = new Vector2(input.MouseState.X, input.MouseState.Y);

            //Check if DropDows is collapsed
            if (_collapsed)
            {
                //Check if Mouse is inside DropDownBox
                if (mousePosition.X >= Position.X && mousePosition.Y >= Position.Y &&
                    mousePosition.X <= Position.X + Size.X &&
                    mousePosition.Y <= Position.Y + Size.Y)
                {
                    _hovered = true;

                    if (!_playedHoverSound && HoverSound != null)
                    {
                        HoverSound.Play();
                        _playedHoverSound = true;
                    }

                    if (input.LeftMouseClicked)
                    {
                        _collapsed = false;
                    }
                }
                else
                {
                    _playedHoverSound = false;
                    _hovered = false;
                }
            }
            else
            {
                //Check if Item gets selected
                float expandedDropDownSize = Size.Y + (_dropDownItemSize.Y*Items.Count);
                if (mousePosition.X >= Position.X && mousePosition.Y >= Position.Y &&
                    mousePosition.X <= Position.X + Size.X &&
                    mousePosition.Y <= Position.Y + expandedDropDownSize)
                {
                    //Mouse is inside DropDown or DropDownItems
                    if (mousePosition.X >= Position.X && mousePosition.Y >= Position.Y &&
                        mousePosition.X <= Position.X + Size.X &&
                        mousePosition.Y <= Position.Y + Size.Y)
                    {
                        //Mouse is just over DropDown Box
                        if (input.LeftMouseClicked)
                        {
                            _collapsed = true;
                        }
                    }
                    else
                    {
                        //Mouse Clicked an DropDownItem!
                        if (input.LeftMouseClicked)
                        {
                            double selectedItem = Math.Floor((mousePosition.Y - Position.Y)/_dropDownItemSize.Y);

                            if (selectedItem - 1 < Items.Count)
                            {
                                SelectedItem = Items[(int) (selectedItem - 1)];
                                OnSelectionChanged(new EventArgs());
                            }
                            _collapsed = true;
                        }
                    }
                }
                else
                {
                    if (input.LeftMouseClicked)
                    {
                        _collapsed = true;
                    }
                }
            }
        }
예제 #7
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     base.HandleInput(gameTime, input);
 }
예제 #8
0
        private void UpdateInput(GameTime gameTime, InputState inputState)
        {
            var keyboardState = inputState.KeyboardState;
            var position = Position.Real;
            var direction = Direction;
            float distance= moving_speed_s / 60.0f; // the distance this object can move during this update
            float angle   = turning_speed_s / 60.0f; // the angle by which this object can turn during this update

            if (keyboardState.IsKeyDown (Keys.Up)) {
                direction.X -= angle;
            }
            if (keyboardState.IsKeyDown (Keys.Down)) {
                direction.X += angle;
            }
            if (keyboardState.IsKeyDown (Keys.Left)) {
                direction.Y -= angle;
            }
            if (keyboardState.IsKeyDown (Keys.Right)) {
                direction.Y += angle;
            }
            Direction=direction;

            //again, for easier understanding of the code...
            bool keyLeft =  keyboardState.IsKeyDown (Keys.A);
            bool keyRight = keyboardState.IsKeyDown (Keys.D);
            bool keyFore =  keyboardState.IsKeyDown (Keys.W);
            bool keyBack =  keyboardState.IsKeyDown (Keys.S);

            if (keyLeft) {
                //            use triangular functions
                //            so we move around the floor
                //            according to "Direction"
                //                                            multiplying by "sqrt2" asserts that
                //                                            this object can not move faster than
                //                                            "distance" by using two non-linear
                //                                            directions (e.g. forewards and
                //                                            sidewards) at the same time
                position.X -= cos (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
                position.Z -= sin (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
            }
            if (keyRight) {
                position.X += cos (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
                position.Z += sin (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
            }
            if (keyFore) {
                position.Z -= cos (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
                position.X += sin (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
            }
            if (keyBack) {
                position.Z -= cos (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
                position.X += sin (Direction.Y) * distance * (keyFore || keyBack ? sqrt2 : 1.0f);
            }
            Position.Real = position;
        }
예제 #9
0
 public virtual void Update(GameTime gameTime, InputState inputState)
 {
     Position.UpdateVisual(gameTime.TotalGameTime);
 }
예제 #10
0
 public override void HandleInput(InputState input)
 {
     base.HandleInput(input);
 }
예제 #11
0
 public void HandleInput(InputState input)
 {
 }
예제 #12
0
        public virtual void HandleInput(InputState input)
        {
            if (input.MouseState.IsMouseIn(Position, Size))
            {
                IsHovered = true;

                if (!_playedHoverSound && HoverSound != null)
                {
                    HoverSound.Play();
                    _playedHoverSound = true;
                }

                if (input.LeftMouseClicked)
                {
                    OnClicked();
                }
            }
            else
            {
                IsHovered = false;
                _playedHoverSound = false;
            }
        }
예제 #13
0
 public ScreenManager(Game game)
     : base(game)
 {
     TraceEnabled = false;
     _input = new InputState();
 }