mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-25 08:22:15 +00:00
renamed circle to be consistent with the other shapes
This commit is contained in:
@@ -10,9 +10,9 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_ConstructorsAndProperties()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
|
||||
Assert.AreEqual(new Circle() { Center = new Vector2(200.0f, 300.0f), Radius = 100.0f }, circle);
|
||||
Assert.AreEqual(new CircleF() { Center = new Vector2(200.0f, 300.0f), Radius = 100.0f }, circle);
|
||||
Assert.AreEqual(200.0f - 100.0f, circle.Left);
|
||||
Assert.AreEqual(200.0f + 100.0f, circle.Right);
|
||||
Assert.AreEqual(300.0f - 100.0f, circle.Top);
|
||||
@@ -21,14 +21,14 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
Assert.AreEqual(new Vector2(200.0f, 300.0f), circle.Center);
|
||||
Assert.AreEqual(100.0f, circle.Radius);
|
||||
Assert.AreEqual(false, circle.IsEmpty);
|
||||
Assert.AreEqual(true, new Circle().IsEmpty);
|
||||
Assert.AreEqual(new Circle(), Circle.Empty);
|
||||
Assert.AreEqual(true, new CircleF().IsEmpty);
|
||||
Assert.AreEqual(new CircleF(), CircleF.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Circle_ContainsPoint()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
|
||||
var p1 = new Point(-1, -1);
|
||||
var p2 = new Point(110, 300);
|
||||
@@ -59,7 +59,7 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_ContainsVector2()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
|
||||
var p1 = new Vector2(-1, -1);
|
||||
var p2 = new Vector2(110, 300);
|
||||
@@ -90,7 +90,7 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_ContainsFloats()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
|
||||
float x1 = -1; float y1 = -1;
|
||||
float x2 = 110; float y2 = 300;
|
||||
@@ -108,11 +108,11 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_ContainsCircle()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle1 = new Circle(new Vector2(199.0f, 299.0f), 100.0f);
|
||||
var circle2 = new Circle(new Vector2(200.0f, 300.0f), 25.0f);
|
||||
var circle3 = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle4 = new Circle(new Vector2(201.0f, 301.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle1 = new CircleF(new Vector2(199.0f, 299.0f), 100.0f);
|
||||
var circle2 = new CircleF(new Vector2(200.0f, 300.0f), 25.0f);
|
||||
var circle3 = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle4 = new CircleF(new Vector2(201.0f, 301.0f), 100.0f);
|
||||
|
||||
bool result;
|
||||
|
||||
@@ -137,10 +137,10 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_IntersectionTest()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
|
||||
var circ1 = new Circle(new Vector2(350.0f, 300.0f), 100.0f);
|
||||
var circ2 = new Circle(new Vector2(400.0f, 300.0f), 100.0f);
|
||||
var circ1 = new CircleF(new Vector2(350.0f, 300.0f), 100.0f);
|
||||
var circ2 = new CircleF(new Vector2(400.0f, 300.0f), 100.0f);
|
||||
|
||||
var rect1 = new Rectangle(250, 300, 100, 100);
|
||||
var rect2 = new Rectangle(400, 300, 100, 100);
|
||||
@@ -167,21 +167,21 @@ namespace MonoGame.Extended.Tests.Shapes
|
||||
[Test]
|
||||
public void Circle_Inflate()
|
||||
{
|
||||
var circle = new Circle(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
var circle = new CircleF(new Vector2(200.0f, 300.0f), 100.0f);
|
||||
circle.Inflate(100.0f);
|
||||
Assert.AreEqual(new Circle(new Vector2(100.0f, 200.0f), 300.0f), circle);
|
||||
Assert.AreEqual(new CircleF(new Vector2(100.0f, 200.0f), 300.0f), circle);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Circle_ToStringTest()
|
||||
{
|
||||
Assert.AreEqual("{Center:{X:200 Y:300} Radius:100}", new Circle(new Vector2(200.0f, 300.0f), 100.0f).ToString());
|
||||
Assert.AreEqual("{Center:{X:200 Y:300} Radius:100}", new CircleF(new Vector2(200.0f, 300.0f), 100.0f).ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Circle_ToRectangleTest()
|
||||
{
|
||||
var actual = new Circle(center: new Vector2(200, 300), radius: 100).ToRectangle();
|
||||
var actual = new CircleF(center: new Vector2(200, 300), radius: 100).ToRectangle();
|
||||
var expected = new Rectangle(100, 200, 200, 200);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<Compile Include="IUpdate.cs" />
|
||||
<Compile Include="Maps\Tiled\CollisionWorldExtensions.cs" />
|
||||
<Compile Include="Maps\Tiled\TiledMapOrientation.cs" />
|
||||
<Compile Include="Shapes\Circle.cs" />
|
||||
<Compile Include="Shapes\CircleF.cs" />
|
||||
<Compile Include="Shapes\PolygonF.cs" />
|
||||
<Compile Include="Shapes\RectangleF.cs" />
|
||||
<Compile Include="Shapes\RectangleExtensions.cs" />
|
||||
|
||||
+80
-80
@@ -10,32 +10,32 @@ namespace MonoGame.Extended.Shapes
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[DebuggerDisplay("{DebugDisplayString,nq}")]
|
||||
public struct Circle : IEquatable<Circle>
|
||||
public struct CircleF : IEquatable<CircleF>
|
||||
{
|
||||
private static readonly Circle _empty = new Circle();
|
||||
private static readonly CircleF _empty = new CircleF();
|
||||
|
||||
/// <summary>
|
||||
/// The point representing the center of this <see cref="Circle"/>.
|
||||
/// The point representing the center of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public Vector2 Center { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The radius from the center of this <see cref="Circle"/>.
|
||||
/// The radius from the center of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public float Radius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Circle"/> with Point = Vector2.Zero and Radius= 0.
|
||||
/// Returns a <see cref="CircleF"/> with Point = Vector2.Zero and Radius= 0.
|
||||
/// </summary>
|
||||
public static Circle Empty
|
||||
public static CircleF Empty
|
||||
{
|
||||
get { return _empty; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the far left point of this <see cref="Circle"/>.
|
||||
/// Returns the x coordinate of the far left point of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
public float Left
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the x coordinate of the far right point of this <see cref="Circle"/>.
|
||||
/// Returns the x coordinate of the far right point of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
public float Right
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the far top point of this <see cref="Circle"/>.
|
||||
/// Returns the y coordinate of the far top point of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
public float Top
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the y coordinate of the far bottom point of this <see cref="Circle"/>.
|
||||
/// Returns the y coordinate of the far bottom point of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
public float Bottom
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The center coordinates of this <see cref="Circle"/>.
|
||||
/// The center coordinates of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
public Point Location
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the diameter of this <see cref="Circle"/>
|
||||
/// Returns the diameter of this <see cref="CircleF"/>
|
||||
/// </summary>
|
||||
public float Diameter
|
||||
{
|
||||
@@ -84,7 +84,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Circumference of this <see cref="Circle"/>
|
||||
/// Returns the Circumference of this <see cref="CircleF"/>
|
||||
/// </summary>
|
||||
public float Circumference
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not this <see cref="Circle"/> has a <see cref="Center"/> and
|
||||
/// Whether or not this <see cref="CircleF"/> has a <see cref="Center"/> and
|
||||
/// <see cref="Radius"/> of 0.
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
@@ -106,12 +106,12 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Circle"/> struct, with the specified
|
||||
/// Creates a new instance of <see cref="CircleF"/> struct, with the specified
|
||||
/// position, and radius
|
||||
/// </summary>
|
||||
/// <param name="center">The position of the center of the created <see cref="Circle"/>.</param>
|
||||
/// <param name="radius">The radius of the created <see cref="Circle"/>.</param>
|
||||
public Circle(Vector2 center, float radius)
|
||||
/// <param name="center">The position of the center of the created <see cref="CircleF"/>.</param>
|
||||
/// <param name="radius">The radius of the created <see cref="CircleF"/>.</param>
|
||||
public CircleF(Vector2 center, float radius)
|
||||
: this()
|
||||
{
|
||||
Center = center;
|
||||
@@ -119,32 +119,32 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Circle"/> instances are equal.
|
||||
/// Compares whether two <see cref="CircleF"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Circle"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="Circle"/> instance on the right of the equal sign.</param>
|
||||
/// <param name="a"><see cref="CircleF"/> instance on the left of the equal sign.</param>
|
||||
/// <param name="b"><see cref="CircleF"/> instance on the right of the equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator ==(Circle a, Circle b)
|
||||
public static bool operator ==(CircleF a, CircleF b)
|
||||
{
|
||||
return ((a.Center == b.Center) && a.Radius.Equals(b.Radius));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether two <see cref="Circle"/> instances are not equal.
|
||||
/// Compares whether two <see cref="CircleF"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="a"><see cref="Circle"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="Circle"/> instance on the right of the not equal sign.</param>
|
||||
/// <param name="a"><see cref="CircleF"/> instance on the left of the not equal sign.</param>
|
||||
/// <param name="b"><see cref="CircleF"/> instance on the right of the not equal sign.</param>
|
||||
/// <returns><c>true</c> if the instances are not equal; <c>false</c> otherwise.</returns>
|
||||
public static bool operator !=(Circle a, Circle b)
|
||||
public static bool operator !=(CircleF a, CircleF b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point at the edge of this <see cref="Circle"/> from the provided angle
|
||||
/// Gets the point at the edge of this <see cref="CircleF"/> from the provided angle
|
||||
/// </summary>
|
||||
/// <param name="angle">an angle in radians</param>
|
||||
/// <returns><see cref="Vector2"/> representing the point on this <see cref="Circle"/>'s surface at the specified angle</returns>
|
||||
/// <returns><see cref="Vector2"/> representing the point on this <see cref="CircleF"/>'s surface at the specified angle</returns>
|
||||
public Vector2 GetPointAlongEdge(float angle)
|
||||
{
|
||||
return new Vector2(Center.X + (Radius * (float)Math.Cos(angle)),
|
||||
@@ -153,62 +153,62 @@ namespace MonoGame.Extended.Shapes
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided coordinates lie within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the point to check for containment.</param>
|
||||
/// <param name="y">The y coordinate of the point to check for containment.</param>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
/// <returns><c>true</c> if the provided coordinates lie inside this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(float x, float y)
|
||||
{
|
||||
return ((new Vector2(x, y) - Center).LengthSquared() <= Radius * Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Point value)
|
||||
{
|
||||
return ((value.ToVector2() - Center).LengthSquared() <= Radius * Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="Point"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="Circle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Point"/> lies inside this <see cref="CircleF"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Point value, out bool result)
|
||||
{
|
||||
result = ((value.ToVector2() - Center).LengthSquared() <= Radius * Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Vector2 value)
|
||||
{
|
||||
return ((value - Center).LengthSquared() <= Radius * Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="Vector2"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="Circle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
/// <param name="value">The coordinates to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Vector2"/> lies inside this <see cref="CircleF"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Vector2 value, out bool result)
|
||||
{
|
||||
result = ((value - Center).LengthSquared() <= Radius * Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Circle"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="CircleF"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Circle"/> to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="Circle"/>'s center lie entirely inside this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(Circle value)
|
||||
/// <param name="value">The <see cref="CircleF"/> to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <returns><c>true</c> if the provided <see cref="CircleF"/>'s center lie entirely inside this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Contains(CircleF value)
|
||||
{
|
||||
var distanceOfCenter = value.Center - Center;
|
||||
var radii = Radius - value.Radius;
|
||||
@@ -217,11 +217,11 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the provided <see cref="Circle"/> lies within the bounds of this <see cref="Circle"/>.
|
||||
/// Gets whether or not the provided <see cref="CircleF"/> lies within the bounds of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="Circle"/> to check for inclusion in this <see cref="Circle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="Circle"/>'s center lie entirely inside this <see cref="Circle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref Circle value, out bool result)
|
||||
/// <param name="value">The <see cref="CircleF"/> to check for inclusion in this <see cref="CircleF"/>.</param>
|
||||
/// <param name="result"><c>true</c> if the provided <see cref="CircleF"/>'s center lie entirely inside this <see cref="CircleF"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Contains(ref CircleF value, out bool result)
|
||||
{
|
||||
var distanceOfCenter = value.Center - Center;
|
||||
var radii = Radius - value.Radius;
|
||||
@@ -236,23 +236,23 @@ namespace MonoGame.Extended.Shapes
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is Circle) && this == ((Circle)obj);
|
||||
return (obj is CircleF) && this == ((CircleF)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares whether current instance is equal to specified <see cref="Circle"/>.
|
||||
/// Compares whether current instance is equal to specified <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="other">The <see cref="Circle"/> to compare.</param>
|
||||
/// <param name="other">The <see cref="CircleF"/> to compare.</param>
|
||||
/// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
|
||||
public bool Equals(Circle other)
|
||||
public bool Equals(CircleF other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code of this <see cref="Circle"/>.
|
||||
/// Gets the hash code of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <returns>Hash code of this <see cref="Circle"/>.</returns>
|
||||
/// <returns>Hash code of this <see cref="CircleF"/>.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// ReSharper disable NonReadonlyMemberInGetHashCode
|
||||
@@ -261,7 +261,7 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the size of this <see cref="Circle"/> by specified radius amount.
|
||||
/// Adjusts the size of this <see cref="CircleF"/> by specified radius amount.
|
||||
/// </summary>
|
||||
/// <param name="radiusAmount">Value to adjust the radius by.</param>
|
||||
public void Inflate(float radiusAmount)
|
||||
@@ -271,11 +271,11 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Circle"/> intersects with this <see cref="Circle"/>.
|
||||
/// Gets whether or not a specified <see cref="CircleF"/> intersects with this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Other <see cref="Circle"/>.</param>
|
||||
/// <returns><c>true</c> if other <see cref="Circle"/> intersects with this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(Circle value)
|
||||
/// <param name="value">Other <see cref="CircleF"/>.</param>
|
||||
/// <returns><c>true</c> if other <see cref="CircleF"/> intersects with this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(CircleF value)
|
||||
{
|
||||
var distanceOfCenter = value.Center - Center;
|
||||
var radii = Radius + value.Radius;
|
||||
@@ -284,11 +284,11 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Circle"/> intersects with this <see cref="Circle"/>.
|
||||
/// Gets whether or not a specified <see cref="CircleF"/> intersects with this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Other <see cref="Circle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Circle"/> intersects with this <see cref="Circle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref Circle value, out bool result)
|
||||
/// <param name="value">Other <see cref="CircleF"/>.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="CircleF"/> intersects with this <see cref="CircleF"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref CircleF value, out bool result)
|
||||
{
|
||||
var distanceOfCenter = value.Center - Center;
|
||||
var radii = Radius + value.Radius;
|
||||
@@ -297,10 +297,10 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Rectangle"/> intersects with this <see cref="Circle"/>.
|
||||
/// Gets whether or not a specified <see cref="Rectangle"/> intersects with this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Other <see cref="Rectangle"/>.</param>
|
||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this <see cref="Circle"/>; <c>false</c> otherwise.</returns>
|
||||
/// <returns><c>true</c> if other <see cref="Rectangle"/> intersects with this <see cref="CircleF"/>; <c>false</c> otherwise.</returns>
|
||||
public bool Intersects(Rectangle value)
|
||||
{
|
||||
var distance = new Vector2(Math.Abs(Center.X - value.X), Math.Abs(Center.Y - value.Y));
|
||||
@@ -327,57 +327,57 @@ namespace MonoGame.Extended.Shapes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not a specified <see cref="Rectangle"/> intersects with this <see cref="Circle"/>.
|
||||
/// Gets whether or not a specified <see cref="Rectangle"/> intersects with this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Other <see cref="Rectangle"/>.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this <see cref="Circle"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
/// <param name="result"><c>true</c> if other <see cref="Rectangle"/> intersects with this <see cref="CircleF"/>; <c>false</c> otherwise. As an output parameter.</param>
|
||||
public void Intersects(ref Rectangle value, out bool result)
|
||||
{
|
||||
result = Intersects(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Circle"/>.
|
||||
/// Changes the <see cref="Location"/> of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="Circle"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="Circle"/>.</param>
|
||||
/// <param name="offsetX">The x coordinate to add to this <see cref="CircleF"/>.</param>
|
||||
/// <param name="offsetY">The y coordinate to add to this <see cref="CircleF"/>.</param>
|
||||
public void Offset(float offsetX, float offsetY)
|
||||
{
|
||||
Offset(new Vector2(offsetX, offsetY));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Circle"/>.
|
||||
/// Changes the <see cref="Location"/> of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Circle"/>.</param>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="CircleF"/>.</param>
|
||||
public void Offset(Point amount)
|
||||
{
|
||||
Offset(amount.ToVector2());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="Location"/> of this <see cref="Circle"/>.
|
||||
/// Changes the <see cref="Location"/> of this <see cref="CircleF"/>.
|
||||
/// </summary>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="Circle"/>.</param>
|
||||
/// <param name="amount">The x and y components to add to this <see cref="CircleF"/>.</param>
|
||||
public void Offset(Vector2 amount)
|
||||
{
|
||||
Center += new Vector2(amount.X, amount.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="Circle"/> in the format:
|
||||
/// Returns a <see cref="String"/> representation of this <see cref="CircleF"/> in the format:
|
||||
/// {Center:[<see cref="Center"/>] Radius:[<see cref="Radius"/>]}
|
||||
/// </summary>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="Circle"/>.</returns>
|
||||
/// <returns><see cref="String"/> representation of this <see cref="CircleF"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{{Center:{0} Radius:{1}}}", Center, Radius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Rectangle"/> large enough to fit this <see cref="Circle"/>
|
||||
/// Creates a <see cref="Rectangle"/> large enough to fit this <see cref="CircleF"/>
|
||||
/// </summary>
|
||||
/// <returns><see cref="Rectangle"/> which contains this <see cref="Circle"/></returns>
|
||||
/// <returns><see cref="Rectangle"/> which contains this <see cref="CircleF"/></returns>
|
||||
public Rectangle ToRectangle()
|
||||
{
|
||||
return new Rectangle((int)(Center.X - Radius), (int)(Center.Y - Radius), (int)Radius * 2, (int)Radius * 2);
|
||||
@@ -11,14 +11,14 @@ namespace SpaceGame.Entities
|
||||
public Meteor(TextureRegion2D textureRegion, Vector2 velocity)
|
||||
{
|
||||
_sprite = new Sprite(textureRegion);
|
||||
_shape = new Circle(_sprite.Position, _radius);
|
||||
_shape = new CircleF(_sprite.Position, _radius);
|
||||
Velocity = velocity;
|
||||
HealthPoints = 10;
|
||||
}
|
||||
|
||||
private const float _radius = 55f;
|
||||
private readonly Sprite _sprite;
|
||||
private Circle _shape;
|
||||
private CircleF _shape;
|
||||
|
||||
public int HealthPoints { get; private set; }
|
||||
public Vector2 Velocity { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user