Example #1
0
        public virtual void MouseEvent()
        {
            if (dragged == null)
            {
                foreach (GameObject interactableGameObject in gameObjects)
                {
                    if (interactableGameObject is InteractableGameObject)
                    {
                        if (interactableGameObject.visible)
                        {
                            InteractableGameObject temp = (InteractableGameObject)interactableGameObject;
                            if (interactableGameObject.rectangle.Intersects(cursorRectangle))
                            {
                                highlighted = temp;
                                if (cursor.clicking)
                                {
                                    clicked = temp;
                                }
                                else
                                {
                                    clicked = null;
                                }
                            }
                        }
                    }
                }
            }

            if (highlighted != null)
            {
                if (!highlighted.rectangle.Intersects(cursorRectangle))
                {
                    highlighted = null;
                    clicked = null;
                }
            }
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            this.cursorRectangle.X = cursor.mouse.X;
            this.cursorRectangle.Y = cursor.mouse.Y;

            lastHighlighted = highlighted;

            base.Update(gameTime);

            MouseEvent();
        }
Example #3
0
 public override void Stop()
 {
     base.Stop();
     this.cursorRectangle = Rectangle.Empty;
     this.highlighted = null;
     this.lastHighlighted = null;
     this.clicked = null;
     this.dragged = null;
     this.lastDragged = null;
 }