protected bool RemoveOnMapCollision(MapTreeHolder map, IProjectile projectile, out Vector2Object hit) { hit = null; if (CompareF.LineVsMap(map, _track).Count > 0) { hit = CompareF.NearestVector(_track.Line.Start, CompareF.LineVsMap(map, _track)); Game1.mapLive.MapProjectiles.Remove(projectile); return(true); } return(false); }
protected bool OutOfmap(IProjectile projectile, out Vector2Object hitPos) { hitPos = null; if (CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track).Count > 0) { hitPos = CompareF.NearestVector(_track.Line.Start, CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track)); Game1.mapLive.MapProjectiles.Remove(projectile); return(true); } return(false); }
protected virtual bool CollisionWithMovables(Map map, IProjectile projectile, out Vector2Object hit) { foreach (IRectanglePhysics rec in map.MapMovables) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(rec, new LineObject(rec, _track.Line)); if (intersections?.Count > 0) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = CompareF.NearestVector(_track.Line.Start, intersections); return(true); } if (CompareF.RectangleVsVector2(rec, _track.Line.End) == true) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = new Vector2Object(rec, _track.Line.End); return(true); } } hit = null; return(false); }