private void CheckLines() { List> rowsToBreak = new List>(); particleSys.BasicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, Engine.Width, Engine.Height, 0, 0, 1); for (int i = columns - 1; i >= 0; i--) { float row = Y + (blockHeight * i) + (blockHeight / 2); Vector3 start = new Vector3(X, row, 0); Vector3 end = new Vector3(X + Width, row, 0); List blocks = new List(); OrientedBoundingBox bb = new OrientedBoundingBox(start, end); bb.Transforms = Matrix.Identity; int collision = 0; for (int a = 0; a < Blocks.Count; a++) { if (bb.Intersects(Blocks[a].BoundingBox)) { blocks.Add(Blocks[a]); } } if (blocks.Count == rows) { rowsToBreak.Add(blocks); for (int j = i - 1; j >= 0; j--) { row = Y + (blockHeight * j) + (blockHeight / 2); start = new Vector3(X, row, 0); end = new Vector3(X + Width, row, 0); bb = new OrientedBoundingBox(start, end); bb.Transforms = Matrix.Identity; for (int k = 0; k < Blocks.Count; k++) { Block b = Blocks[k]; if (bb.Intersects(b.BoundingBox)) { b.Vertices[0].Y += blockHeight; b.Vertices[1].Y += blockHeight; b.Vertices[2].Y += blockHeight; b.Vertices[3].Y += blockHeight; } } } } } for (int i = 0; i < rowsToBreak.Count; i++) { for (int a = 0; a < rowsToBreak[i].Count; a++) { float minX = rowsToBreak[i][a].Vertices[0].X; float maxX = rowsToBreak[i][a].Vertices[2].X; float minY = rowsToBreak[i][a].Vertices[1].Y; float maxY = rowsToBreak[i][a].Vertices[3].Y; for (int j = 0; j < particleCount; j++) { Vector2 explosionOrigin = new Vector2(Utility.RandomFloatMinMax(minX, maxX), Utility.RandomFloatMinMax(minY, maxY)); float xSpeed = Utility.RandomMinMax(-100, 100); float ySpeed = Utility.RandomMinMax(-100, 100); float rotation = Utility.RandomFloatMinMax(0, MathHelper.Pi); float lifeTime = Utility.RandomMinMax(1, 4); float rotationSpeed = Utility.RandomFloatMinMax(0, MathHelper.Pi * 3); VertexPositionColor[] vertices = new VertexPositionColor[] { new VertexPositionColor(new Vector3(Utility.RandomMinMax(-3, -1), 0, 0), rowsToBreak[i][a].Color), new VertexPositionColor(new Vector3(Utility.RandomMinMax(1, 3), 0, 0), rowsToBreak[i][a].Color) }; particleSys.Add(explosionOrigin, new Vector2(xSpeed, ySpeed), lifeTime, rotation, rotationSpeed, vertices); } Blocks.Remove(rowsToBreak[i][a]); } } }