private static async Task MatchUnconnectedVerticalOrbs(List<PuzzlePiece> puzzlePieces) { puzzlePieces = puzzlePieces.OrderBy(pp => pp.Location.Row).ToList(); for (int pieceIndex = 0; pieceIndex < puzzlePieces.Count; pieceIndex++) { var matchingNeighbors = GetMatchingColumnNeighbors(puzzlePieces[pieceIndex], puzzlePieces); if (matchingNeighbors.Count >= 3) { MarkAllOrbs(matchingNeighbors); OrbMatches.Add(new OrbMatch(matchingNeighbors[0].Type, matchingNeighbors.Count, false)); var matchAnimator = new OrbMatchAnimator(OrbMatches.Count); await matchAnimator.AnimateVerticalMatch(matchingNeighbors); } } }
private static async Task MatchHorizontalOrbsAndTheirVerticalConnections(List<PuzzlePiece> puzzlePieces) { puzzlePieces = puzzlePieces.OrderBy(pp => pp.Location.Column).ToList(); for (int pieceIndex = 0; pieceIndex < puzzlePieces.Count; pieceIndex++) { var matchingNeighbors = GetMatchingRowNeighbors(puzzlePieces[pieceIndex], puzzlePieces); if (matchingNeighbors.Count >= 3) { matchingNeighbors = CheckNorthAndSouth(matchingNeighbors, puzzlePieces); matchingNeighbors = matchingNeighbors.Distinct().ToList(); MarkAllOrbs(matchingNeighbors); OrbMatches.Add(new OrbMatch(matchingNeighbors[0].Type, matchingNeighbors.Count, true)); var matchAnimator = new OrbMatchAnimator(OrbMatches.Count); await matchAnimator.AnimateHorizontalMatch(matchingNeighbors); } } }