public override void Update(GameTime gameTime) { bool atBlankSpace = true; MouseState mouse = Mouse.GetState(); for (int i = 0; i < clickables.Count; i++) { IClickable clickable = clickables[i]; if (Toolbox.IsPointInsideSquare(new Point(mouse.X, mouse.Y), clickable.GetBoundary())) { atBlankSpace = false; clickable.MouseEnter(); if (mouse.LeftButton == ButtonState.Pressed) { clickable.Click(); } else { clickable.Release(); } } else { clickable.MouseLeave(); } } if (atBlankSpace && mouse.LeftButton == ButtonState.Pressed) { heroDetail?.Deactivate(); } base.Update(gameTime); }
/// <summary> /// Checks if given point value is inside of this socket's boundary. /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> public bool IsInside(int x, int y) { if (Toolbox.IsPointInsideSquare(this.x, this.y, this.x + width, this.y + height, x, y)) { return(true); } return(false); }
public bool IsInside(int x, int y) { return(Toolbox.IsPointInsideSquare(this.x, this.y, this.x + WIDTH, this.y + HEIGHT, x, y)); }