public static MoveCollection CalcMoves(FTLPair pair, Cube cube) { MoveCollection moves = new MoveCollection(); FTLMoveCalculator.cube = (Cube)cube.Clone(); FTLMoveCalculator.cube.OnMoveDone += Cube_OnMoveDone; pairs = from corner in FTLMoveCalculator.cube.Corners where corner.HasColor(WHITE) select FTLPair.GetPair(corner, FTLMoveCalculator.cube); FTLPair newPair = pairs.First(p => p == pair); void DoMove(CubeFace face, int count) { if (count == 0) { return; } Move m = new Move(face, count); FTLMoveCalculator.cube.DoMove(m); moves.Add(m); } FTLMoveCalculator.DoMove += DoMove; CalcPairMoves(newPair); FTLMoveCalculator.DoMove -= DoMove; return(moves); }
protected void DoMove(CubeFace face, int count = 1, bool addMove = true) { if (count == 0) { return; } cube.DoMove(face, count); if (addMove) { moves.Add(face, count); } }