示例#1
0
        public override void Update(GameTime gameTime)
        {
            if (GetInformation != null)
            {
                Information = GetInformation();
            }

            if (GetRectangle != null)
            {
                Rectangle = GetRectangle();
            }

            if (GameMouse.Intersects(Rectangle))
            {
                OnHover?.Invoke();
                IsHover = true;

                if (GameMouse.IsLeftClicked)
                {
                    OnSelected?.Invoke();
                    IsSelected = true;
                }
            }
            else
            {
                OffHover.Invoke();
                IsHover = false;

                if (GameMouse.IsLeftClicked && !GameKeyboard.IsKeyDown(Keys.LeftShift))
                {
                    OffSelected?.Invoke();
                    IsSelected = false;
                }
            }
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            _previousScroll = _currentScroll;
            _currentScroll  = GameMouse.ScrollWheelValue;

            var speed = 0.15f;

            if (_previousScroll < _currentScroll)
            {
                _scale *= 1f + speed;
            }
            else if (_previousScroll > _currentScroll)
            {
                _scale *= 1f - speed;
            }

            if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                _scale *= 1.05f;
            }
            else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                _scale *= 0.95f;
            }

            _scale = MathHelper.Clamp(_scale, 1f, 10f);

            _transform = Matrix.CreateTranslation(0, 0, 0) * //new Vector3((_gameModel.ScreenWidth / 2), (_gameModel.ScreenHeight / 2), 0)) *
                         Matrix.CreateScale(_scale);
        }
示例#3
0
        public void Follow(Vector2 followPosition)
        {
            var newPosition = followPosition;

            //newPosition.X = CheckNSet(newPosition.X, MinX);
            //newPosition.Y = CheckNSet(newPosition.Y, MinY);
            //newPosition.X = CheckNSet(newPosition.X, MaxX);
            //newPosition.Y = CheckNSet(newPosition.Y, MaxY);

            if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                Scale += 0.01f;
            }
            else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                Scale -= 0.01f;
            }

            //Scale = 1.57f;// Math.Clamp(Scale, 0.5f, 2.0f);

            Position = newPosition;// Vector2.Lerp(Position, newPosition, 0.05f);
            //Transform = Matrix.CreateTranslation(Position.X, Position.Y, 0);v
            var x = -Position.X + (ZonerGame.ScreenWidth / 2);
            var y = -Position.Y + (ZonerGame.ScreenHeight / 2);

            if (MaxX.HasValue && x > MaxX.Value)
            {
                x = MaxX.Value;
            }

            if (MinX.HasValue && x < MinX.Value)
            {
                x = MinX.Value;
            }

            if (StaticX.HasValue)
            {
                x = StaticX.Value;
            }

            if (MaxY.HasValue && y > MaxY.Value)
            {
                y = MaxY.Value;
            }

            if (MinY.HasValue && y < MinY.Value)
            {
                y = MinY.Value;
            }

            if (StaticY.HasValue)
            {
                y = StaticY.Value;
            }

            Transform = Matrix.CreateTranslation(x, y, 0) *
                        Matrix.CreateScale(Scale, Scale, 1);
        }
示例#4
0
        public void Update()
        {
            if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                Position.X--;
            }
            else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                Position.X++;
            }

            if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                Position.Y++;
            }
            else if (GameKeyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                Position.Y--;
            }
        }
示例#5
0
 private void SetMovementEvent(GameTime gameTime)
 {
     if (GameKeyboard.IsKeyPressed(Keys.D))
     {
         Direction = Directions.Right;
     }
     else if (GameKeyboard.IsKeyPressed(Keys.A))
     {
         Direction = Directions.Left;
     }
     else if (GameKeyboard.IsKeyPressed(Keys.W))
     {
         Direction = Directions.Up;
     }
     else if (GameKeyboard.IsKeyPressed(Keys.S))
     {
         Direction = Directions.Down;
     }
     else if (GameKeyboard.IsKeyDown(Keys.D))
     {
         _moveComponent.Velocity = new Vector2(_moveComponent.Speed, 0);
         Direction = Directions.Right;
     }
     else if (GameKeyboard.IsKeyDown(Keys.A))
     {
         _moveComponent.Velocity = new Vector2(-_moveComponent.Speed, 0);
         Direction = Directions.Left;
     }
     else if (GameKeyboard.IsKeyDown(Keys.W))
     {
         _moveComponent.Velocity = new Vector2(0, -_moveComponent.Speed);
         Direction = Directions.Up;
     }
     else if (GameKeyboard.IsKeyDown(Keys.S))
     {
         _moveComponent.Velocity = new Vector2(0, _moveComponent.Speed);
         Direction = Directions.Down;
     }
 }