public override M_Rectangle GetNoMatrixRectangle() { M_Rectangle rect = new M_Rectangle(0, 0, 0, 0); for (int i = 0; i < masks.Count; i++) { M_Rectangle cRect = masks[i].GetNoMatrixRectangle(); if (i == 0) { rect = cRect; } else { if (cRect.pos.X < rect.pos.X) { rect.X = cRect.pos.X; } if (cRect.pos.Y < rect.pos.Y) { rect.Y = cRect.pos.Y; } if (cRect.size.X > rect.size.X) { rect.size.X = cRect.size.X; } if (cRect.size.Y > rect.size.Y) { rect.size.Y = cRect.size.Y; } } } //rect.pos += this.pos; return(rect); }
public override CollisionResult DistToRectangle(M_Rectangle rectangle) { return(new CollisionResult() { collision = masks.Any(f => f.ColRectangle(rectangle)) }); //return MaxCol(f => f.DistToRectangle(rectangle)); }
public virtual void Draw(SpriteBatch spriteBatch, M_Rectangle destinationRectangle, Color color, float depth = -1f) { if (visible) { if (depth == -1) { depth = this.depth; } Vector2 scale = new Vector2(destinationRectangle.size.X / sizex, destinationRectangle.size.Y / sizey); Vector2 imageOrigin = new Vector2(0, 0); spriteBatch.Draw(texture, (destinationRectangle.pos), new Rectangle(GetSourceX(), GetSourceY(), sizex, sizey), color, rotation, imageOrigin, scale, mirror, depth); } }
public static string ToString(object input) { Type typeIn = input.GetType(); Type typeOut = typeof(string); if (typeIn == typeof(Color)) { Color color = (Color)input; return(color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2")); } else if (typeIn == typeof(M_Rectangle)) { M_Rectangle rect = input as M_Rectangle; return(rect.pos.X.ToString(CultureInfo.InvariantCulture) + "," + rect.pos.Y.ToString(CultureInfo.InvariantCulture) + "," + rect.size.X.ToString(CultureInfo.InvariantCulture) + "," + rect.size.Y.ToString(CultureInfo.InvariantCulture)); } TypeConverter converter = TypeDescriptor.GetConverter(typeIn); if (converter.CanConvertTo(typeOut)) { return(converter.ConvertToInvariantString(input)); } return(""); }
public override M_Rectangle GetRectangle() { Vector2 min = Vector2.Zero, max = Vector2.Zero; for (int i = 0; i < masks.Count; i++) { M_Rectangle cRect = masks[i].GetRectangle(); if (i == 0) { min = cRect.pos; max = cRect.BottomRight; } else { if (cRect.X < min.X) { min.X = cRect.X; } if (cRect.Right > max.X) { max.X = cRect.Right; } if (cRect.Y < min.Y) { min.Y = cRect.Y; } if (cRect.Bottom > max.Y) { max.Y = cRect.Bottom; } } } M_Rectangle rect = new M_Rectangle(min, max - min); //rect.pos += this.pos; return(rect); }
public override CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir) { return(Collision.DistRectanglePolygon(rectangle, this, -dir).GetAxisInvert()); }
public abstract CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir);
public override CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir) { return(MinCol(f => f.DistToRectangle(rectangle, dir))); }
public override bool ColRectangle(M_Rectangle rectangle) { return(masks.Any(f => f.ColRectangle(rectangle))); }
public override CollisionResult DistToRectangle(M_Rectangle rectangle) { return(Collision.DistRectangleCircle(rectangle, this).GetAxisInvert()); }
public override bool ColRectangle(M_Rectangle rectangle) { return(Collision.ColRectangleCircle(rectangle, this)); }
public override CollisionResult DistToRectangle(M_Rectangle rectangle) { throw new NotImplementedException(); }
public abstract bool ColRectangle(M_Rectangle rectangle);
public override CollisionResult DistToRectangle(M_Rectangle rectangle) { return(Collision.DistVectorRectangle(pos, rectangle)); }
public override bool ColRectangle(M_Rectangle rectangle) { return(Collision.ColVectorRectangle(pos, rectangle)); }
public override void Draw(SpriteBatch spriteBatch, M_Rectangle destinationRectangle, Color color, float depth = -1f) { DrawEffect(); base.Draw(spriteBatch, destinationRectangle, color, depth); }
public virtual void Draw(SpriteBatch spriteBatch, Color color, float depth = 0f) { M_Rectangle rect = GetRectangle(); spriteBatch.Draw(DrawM.pixel, rect.pos, new Rectangle(0, 0, 1, 1), color, 0f, Vector2.Zero, rect.size, SpriteEffects.None, depth); }
public abstract CollisionResult DistToRectangle(M_Rectangle rectangle);