public void TryMoveLeft(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { if (labyrinth[row, col - 1] == '-') { labyrinth[row, col] = '-'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('-'); col--; labyrinth[row, col] = '*'; Console.SetCursorPosition(2 * (int)col, (int)row + 3); Console.Write('*'); LabyrinthEngine.currentMoves++; } else { Console.WriteLine("Invalid move!"); } if (col == 0) { LabyrinthEngine.GameEndedCongratAndReset(ref gameInProgress); } }
public void TryMoveLeft(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { if (labyrinth[row, col - 1] == '-') { labyrinth[row, col] = '-'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('-'); col--; labyrinth[row, col] = '*'; Console.SetCursorPosition(2 * (int)col, (int)row + 3); Console.Write('*'); LabyrinthEngine.currentMoves++; } else { Console.WriteLine("Invalid move!"); } if (col == 0) { LabyrinthEngine.GameEndedCongratAndReset(ref gameInProgress); } }
public static void PlayGame(Labyrinth labyrinth, int row, int col) { bool gameInProgress = true; currentMoves = 0; Console.WriteLine("\nEnter your move (Left Arrow = left, Right Arrow = right, Down Arrow = down, Up Arrow = up)"); Console.SetCursorPosition(0, 15); LabyrinthNavigation navigation = new LabyrinthNavigation(); while (gameInProgress) { ConsoleKeyInfo userChoice = Console.ReadKey(true); // Set currsor position outside of labyrinth and deletes previous turn message if any // I think this should be edited latter to not use magic numbers Console.SetCursorPosition(0, 15); ConsoleManipulation.ClearCurrentLine(); switch (userChoice.Key) { case ConsoleKey.LeftArrow: navigation.TryMoveLeft(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.RightArrow: navigation.TryMoveRight(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.DownArrow: navigation.TryMoveDown(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.UpArrow: navigation.TryMoveUp(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.T: PrintTopScores(scores); break; case ConsoleKey.R: gameInProgress = false; break; case ConsoleKey.E: Console.WriteLine("Good bye!"); Environment.Exit(0); break; default: Console.WriteLine("Invalid command!"); break; } } }
public static void PlayGame(Labyrinth labyrinth, int row, int col) { bool gameInProgress = true; currentMoves = 0; Console.WriteLine("\nEnter your move (Left Arrow = left, Right Arrow = right, Down Arrow = down, Up Arrow = up)"); Console.SetCursorPosition(0, 15); LabyrinthNavigation navigation = new LabyrinthNavigation(); while (gameInProgress) { ConsoleKeyInfo userChoice = Console.ReadKey(true); // Set currsor position outside of labyrinth and deletes previous turn message if any // I think this should be edited latter to not use magic numbers Console.SetCursorPosition(0, 15); ConsoleManipulation.ClearCurrentLine(); switch (userChoice.Key) { case ConsoleKey.LeftArrow: navigation.TryMoveLeft(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.RightArrow: navigation.TryMoveRight(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.DownArrow: navigation.TryMoveDown(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.UpArrow: navigation.TryMoveUp(labyrinth, ref gameInProgress, ref row, ref col); break; case ConsoleKey.T: PrintTopScores(scores); break; case ConsoleKey.R: gameInProgress = false; break; case ConsoleKey.E: Console.WriteLine("Good bye!"); Environment.Exit(0); break; default: Console.WriteLine("Invalid command!"); break; } } }
protected static void DisplayLabyrinth(Labyrinth labyrinth) { for (int row = 0; row < labyrinth.LengthX; row++) { StringBuilder rowBuilder = new StringBuilder(2 * (int)labyrinth.LengthY); for (int column = 0; column < labyrinth.LengthY; column++) { rowBuilder.Append(labyrinth[row, column]); rowBuilder.Append(" "); } Console.WriteLine(rowBuilder.ToString()); } Console.WriteLine(); }
protected static void DisplayLabyrinth(Labyrinth labyrinth) { for (int row = 0; row < labyrinth.LengthX; row++) { StringBuilder rowBuilder = new StringBuilder(2 * (int)labyrinth.LengthY); for (int column = 0; column < labyrinth.LengthY; column++) { rowBuilder.Append(labyrinth[row,column]); rowBuilder.Append(" "); } Console.WriteLine(rowBuilder.ToString()); } Console.WriteLine(); }
public void TryMoveDown(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { if (labyrinth[row + 1, col] == '-') { labyrinth[row, col] = '-'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('-'); row++; labyrinth[row, col] = '*'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('*'); LabyrinthEngine.currentMoves++; } else { Console.WriteLine("Invalid move!"); } if (row == LabyrinthRowLength - 1) { LabyrinthEngine.GameEndedCongratAndReset(ref gameInProgress); } }
public void TryMoveDown(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { if (labyrinth[row + 1, col] == '-') { labyrinth[row, col] = '-'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('-'); row++; labyrinth[row, col] = '*'; Console.SetCursorPosition(2 * col, row + 3); Console.Write('*'); LabyrinthEngine.currentMoves++; } else { Console.WriteLine("Invalid move!"); } if (row == LabyrinthRowLength - 1) { LabyrinthEngine.GameEndedCongratAndReset(ref gameInProgress); } }
public void TryMoveLeft(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { throw new NotImplementedException(); }
public void TryMoveLeft(Labyrinth labyrinth, ref bool gameInProgress, ref int row, ref int col) { throw new NotImplementedException(); }