public LevelSolver Clone() { LevelSolver n = new LevelSolver(board.GetLength(0), board.GetLength(1), board.Cast <PieceType>().ToArray()); n.SetGoals(goals.ToArray()); return(n); }
public void ExecuteSolution() { editorManager.SetGameState(EditorManager.GameState.Solving); pieceBoard = boardManager.pieceBoard; PieceType[] board = new PieceType[pieceBoard.Length]; int k = 0; for (int i = pieceBoard.GetLength(1) - 1; i >= 0; i--) { for (int j = 0; j < pieceBoard.GetLength(0); j++) { Piece x = pieceBoard[j, i]; board[k++] = x && x.GetPieceType() != PieceType.objective ? x.GetPieceType() : PieceType.empty; } } LevelSolver newLevelSolver = new LevelSolver(pieceBoard.GetLength(0), pieceBoard.GetLength(1), board); newLevelSolver.SetGoals(new Tuple <int, int>(pieceBoard.GetLength(0) - (int)boardManager.GetObjectivePos().y - 1, (int)boardManager.GetObjectivePos().x)); List <InputHandler.MoveDirection> moveDirections = newLevelSolver.Solve(); if (moveDirections.Count > 0) { print(String.Join(" ", moveDirections.Select(x => x.ToString()))); SaveLevelTemp(moveDirections); } else { print("Nao tem solução!"); } editorManager.SetGameState(EditorManager.GameState.InGame); }