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; } } }
public override void Update(GameTime gameTime) { this.cursorRectangle.X = cursor.mouse.X; this.cursorRectangle.Y = cursor.mouse.Y; lastHighlighted = highlighted; base.Update(gameTime); MouseEvent(); }
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; }