2024-01-24 12:17:21 +03:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
using Apos.Shapes;
|
|
|
|
|
2024-01-31 12:32:16 +03:00
|
|
|
using Syntriax.Engine.Core.Abstract;
|
2024-01-24 12:17:21 +03:00
|
|
|
using Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
|
|
|
|
namespace Pong.Behaviours;
|
|
|
|
|
2024-01-24 19:25:31 +03:00
|
|
|
public class ShapeBehaviour : Syntriax.Engine.Physics2D.Collider2DShapeBehaviour, IDisplayableShape
|
2024-01-24 12:17:21 +03:00
|
|
|
{
|
2024-01-27 21:50:28 +03:00
|
|
|
public ShapeBehaviour(Shape shape) : base(shape) { }
|
|
|
|
public ShapeBehaviour(Shape shape, float thickness) : base(shape) { Thickness = thickness; }
|
|
|
|
public ShapeBehaviour(Shape shape, Color color) : base(shape) { Color = color; }
|
|
|
|
public ShapeBehaviour(Shape shape, Color color, float thickness) : base(shape) { Thickness = thickness; Color = color; }
|
2024-01-24 12:17:21 +03:00
|
|
|
|
|
|
|
public Color Color { get; set; } = Color.White;
|
|
|
|
public float Thickness { get; set; } = .5f;
|
|
|
|
|
|
|
|
public void Draw(ShapeBatch shapeBatch)
|
|
|
|
{
|
2024-01-28 15:33:15 +03:00
|
|
|
if (!IsActive)
|
|
|
|
return;
|
|
|
|
|
2024-01-27 21:50:28 +03:00
|
|
|
Recalculate();
|
|
|
|
|
2024-01-24 19:25:31 +03:00
|
|
|
int count = ShapeWorld.Vertices.Count;
|
2024-01-24 12:17:21 +03:00
|
|
|
|
2024-01-24 19:25:31 +03:00
|
|
|
for (int i = 0; i < count - 1; i++)
|
|
|
|
shapeBatch.DrawLine(ShapeWorld[i].ToDisplayVector2(), ShapeWorld[i + 1].ToDisplayVector2(), Thickness, Color, Color);
|
|
|
|
shapeBatch.DrawLine(ShapeWorld[0].ToDisplayVector2(), ShapeWorld[^1].ToDisplayVector2(), Thickness, Color, Color);
|
2024-01-24 12:17:21 +03:00
|
|
|
}
|
|
|
|
}
|