public Pyramid(World world, ScreenManager screenManager, Vector2 position, int count, float density)
{
_batch = screenManager.SpriteBatch;
Vertices rect = PolygonTools.CreateRectangle(0.5f, 0.5f);
PolygonShape shape = new PolygonShape(rect, density);
Vector2 rowStart = position;
rowStart.Y -= 0.5f + count * 1.1f;
Vector2 deltaRow = new Vector2(-0.625f, 1.1f);
const float spacing = 1.25f;
_boxes = new List<Body>();
for (int i = 0; i < count; ++i)
{
Vector2 pos = rowStart;
for (int j = 0; j < i + 1; ++j)
{
Body body = BodyFactory.CreateBody(world);
body.BodyType = BodyType.Dynamic;
body.Position = pos;
body.CreateFixture(shape);
_boxes.Add(body);
pos.X += spacing;
}
rowStart += deltaRow;
}
//GFX
AssetCreator creator = screenManager.Assets;
_box = new Sprite(creator.TextureFromVertices(rect, MaterialType.Dots, Color.SaddleBrown, 2f));
}