Пример #1
0
        public void Update(Vector2 cameraPos, GameMouseState getState, Vector2 mouseInWorld)
        {
            CameraPos = cameraPos;
            _Position = cameraPos;

            Location = _Position + new Vector2((float)-(DistanceX * Math.Cos(_Rotation)), (float)-(DistanceX * Math.Sin(_Rotation))) +
                       new Vector2(Size.X * (float)Math.Cos(_Rotation) - Size.X / 2, Size.Y * (float)Math.Sin(_Rotation) - Size.X / 2);

            currentMouseState = getState;

            if (!IsMouseDown &&
                currentMouseState.LeftButton == ButtonState.Pressed &&
                previousMouseState.LeftButton == ButtonState.Released && Rectangle.Contains((int)(mouseInWorld.X), (int)(mouseInWorld.Y)))
            {
                IsMouseDown = false;
                OnMouseDown(mouseInWorld);
            }

            if (IsMouseDown && currentMouseState.LeftButton == ButtonState.Released &&
                previousMouseState.LeftButton == ButtonState.Pressed && Rectangle.Contains((int)(mouseInWorld.X), (int)(mouseInWorld.Y)))
            {
                IsMouseDown = false;
                OnMouseUp(mouseInWorld);
            }

            previousMouseState = currentMouseState;
        }
Пример #2
0
 public override void Update(GameTime gameTime)
 {
     BananaGame.GamePlayer.Update(gameTime);
     if (GameKeyState.IsKeyPressed(Keys.U))
     {
         //GameMouseState.WP();
         Vector2Int blah = new Vector2Int(GameMouseState.WorldPosition());
         highlight = new TileHighlight(blah.asVector2(), Color.Blue);
     }
 }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            PreviousMouseState = CurrentMouseState;
            CurrentMouseState  = GameMouse.GetState();

            if (!Enabled)
            {
                return;
            }
            UpdateCamera();
            FireMouseEvents();
        }
Пример #4
0
        public override void Update(GameTime gameTime)
        {
            var mouseState = GameMouse.GetState();

            if (mouseState.LeftButton == ButtonState.Released && _previousMouseState.LeftButton == ButtonState.Pressed)
            {
                if (!(CurrentlySelectedNode != null && CurrentlySelectedNode.IsMouseDown))
                {
                    // Create a new node, and also set it to be the newest created node
                    if (CurrentlySelectedNode != null)
                    {
                        CurrentlySelectedNode.SetColorState(ColorState.None);
                    }
                    CurrentlySelectedNode = CreateNode((int)World.MouseInWorld.X, (int)World.MouseInWorld.Y);
                    CurrentlySelectedNode.SetColorState(ColorState.DarkDark);
                }
            }
            _previousMouseState = mouseState;
        }
Пример #5
0
        public static void Update(int n, GameMouseState state)
        {
            if(n != 0)
            {
                throw new Exception();
            }

            var s = Mouse.GetState();

            States[0] = s.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            States[1] = s.MiddleButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            States[2] = s.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            States[3] = s.XButton1 == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            States[4] = s.XButton2 == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

            state.UpdateState(
                s.X,
                s.Y,
                States,
                s.ScrollWheelValue
            );
        }
Пример #6
0
        public void SelectByMouse()
        {
            Vector2 mouseWorldPosition = GameMouseState.WorldPosition();

            Select(new Vector2Int(mouseWorldPosition));
        }