/// <summary> /// Combines adjacent pieces into MovingBlock objects and adds them to the scene /// </summary> /// <param name="allPieces"></param> public static void CreateBlocks(QuickGameScene scene, IEnumerable <MovingBlockPiece> allPieces, IEnumerable <PathPoint> pathPoints) { var groups = AdjacentTileGroup <MovingBlockPiece> .ExtractGroups(allPieces); var paths = AdjacentTileGroup <PathPoint> .ExtractGroups(pathPoints); //don't like this here scene.SinglePathPoints = paths.Where(p => p.Tiles.Length == 1).Select(p => p.Tiles[0]).ToArray(); paths = paths.Where(p => p.Tiles.Length > 1).ToArray(); foreach (var group in groups) { var groupBox = group.GetBoundingBox(); var path = paths.FirstOrDefault(p => p.Tiles.Any(q => groupBox.CollidesWith(q.Position, false))); if (path != null) { new MovingBlock(scene, group, path); } } }