public override void Update(GameTime gameTime) { // Set course towards target if (CollisionDetection.IsPointInsideRectangle(target.position, ship.view) && target.position != Vector2.Zero) { if (target is PlayerOverworld && ((ship is RebelShip && StatsManager.reputation >= 0) || ((ship is AllianceShip || ship is HangarShip) && StatsManager.reputation < 0))) { if (OverworldShip.FollowPlayer && !InRestrictedSpace(ship, target.position)) { ship.destination = target.position; Finished = true; } else { Finished = false; } } else if (!(target is PlayerOverworld)) { ship.destination = target.position; Finished = true; } } else { Finished = false; } }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (dest == Vector2.Zero || CollisionDetection.IsPointInsideRectangle(ship.destination, ship.Bounds) || InRestrictedSpace(ship, ship.destination)) { SetRandomDest(); } ship.destination = dest; }
protected Boolean IsTargeted() { if (CollisionDetection.IsPointInsideRectangle(new Vector2(currentMouse.X, currentMouse.Y), collisionZone)) { return(true); } return(false); //return CollisionDetection.IsPointInsideRectangle(new Vector2(currentMouse.X + offset.X, currentMouse.Y + offset.Y), collisionZone); }
public static bool InRestrictedSpace(OverworldShip ship, Vector2 point) { foreach (SpaceRegion region in ship.restrictedSpace) { if (CollisionDetection.IsPointInsideRectangle(point, region.SpaceRegionArea)) { return(true); } } return(false); }
public static bool IsMouseOverText(SpriteFont font, String text, Vector2 textPosition, bool textCentered = true) { Vector2 textOrigin; Vector2 textDimension; Rectangle textRect; textOrigin = textCentered ? font.MeasureString(text) / 2 : Vector2.Zero; textDimension = font.MeasureString(text); textRect = new Rectangle((int)(textPosition.X - textOrigin.X), (int)(textPosition.Y - textOrigin.Y), (int)textDimension.X, (int)textDimension.Y); return(showMouse && CollisionDetection.IsPointInsideRectangle(ControlManager.GetMousePosition(), textRect)); }
public static bool IsMouseOverArea(Rectangle area) { return(showMouse && CollisionDetection.IsPointInsideRectangle(new Vector2(currentMouseState.X, currentMouseState.Y), area)); }