public void Update(IEntities entities, TimeSpan delta)
        {
            _mouse = _mouse.Current();

            if (!_mouse.IsOnGameScreen)
            {
                return;
            }

            entities.WithTopMost <MouseStateActions>(_mouse.WorldPosition,
                                                     (o, m) =>
            {
                if (!o.World.Intersects(_mouse.WorldPosition))
                {
                    m.Exit();
                }
                else if (!o.World.Intersects(_mouse.LastWorldPosition))
                {
                    m.Hover();
                }
                else if (_mouse.JustPressed(m.Button))
                {
                    m.Click();
                }
                else if (_mouse.JustReleased(m.Button))
                {
                    m.Release();
                }
            },
                                                     (o, m) => m.Exit());
        }
Exemple #2
0
 public void Update(IEntities entities, TimeSpan delta)
 {
     _mouse = _mouse.Current();
     entities.With <MouseDrag>((o, drag) =>
     {
         if ((drag.Button == MouseButton.Right && _mouse.RightStillPressed) ||
             (drag.Button == MouseButton.Left && _mouse.LeftStillPressed) ||
             (drag.Button == MouseButton.Center && _mouse.RightButtonJustPressed))
         {
             o.World.Location -= _mouse.MovedBy.ToVector2();
         }
     });
 }
Exemple #3
0
        public void Update(IEntities entities, TimeSpan delta)
        {
            _mouse = _mouse.Current();

            if (!_mouse.IsOnGameScreen || !_mouse.ButtonJustPressed)
            {
                return;
            }

            entities.With <MouseClickListener>(m => m.OnClick(_mouse.WorldPosition));
            entities.WithTopMost <MouseClickTarget>(_mouse.WorldPosition,
                                                    (o, m) => o.World.If(x => x.Intersects(_mouse.WorldPosition), () => m.OnHit()),
                                                    (o, m) => m.OnMiss());
        }
Exemple #4
0
        public void Update(IEntities entities, TimeSpan delta)
        {
            _mouse = _mouse.Current();

            var zoomDirection = _mouse.MouseWheelDelta.CompareTo(0);

            if (zoomDirection == 0)
            {
                return;
            }

            entities.With <MouseWheelScale>((o, x) =>
                                            o.Local.Scale = o.Local.Scale + x.ScaleAmount * (_mouse.MouseWheelDelta / 120f));
        }
        public void Update(IEntities entities, TimeSpan delta)
        {
            _mouse = _mouse.Current();

            if (!_mouse.IsOnGameScreen)
            {
                return;
            }

            if (_mouse.LeftStillPressed)
            {
                UpdateTarget();
            }
            if (_mouse.LeftButtonJustPressed)
            {
                SelectTarget(entities);
            }
            if (!_mouse.LeftIsPressed)
            {
                DropTarget(entities);
            }
        }