// Checks which key the user pressed private static ICommand GetCommandFromKey(ConsoleKeyInfo consoleKeyInfo) { Command command = null; switch (consoleKeyInfo.Key) { case ConsoleKey.W: case ConsoleKey.UpArrow: command = new MoveUpCommand(); break; case ConsoleKey.S: case ConsoleKey.DownArrow: command = new MoveDownCommand(); break; case ConsoleKey.D: case ConsoleKey.RightArrow: command = new MoveRightCommand(); break; case ConsoleKey.A: case ConsoleKey.LeftArrow: command = new MoveLeftCommand(); break; case ConsoleKey.E: System.Console.WriteLine($"\nYou dig down"); command = new DigCommand(); break; case ConsoleKey.F: Console.WriteLine($"\nYou place a block below you"); command = new PlaceCommand(); break; default: Console.WriteLine("Unknown key"); break; } return(command); }
static ICommand GetCommandFromKey(ConsoleKeyInfo ki) { Command command = null; switch (ki.Key) { case ConsoleKey.W: case ConsoleKey.UpArrow: command = new MoveUpCommand(); break; case ConsoleKey.D: case ConsoleKey.RightArrow: command = new MoveRightCommand(); break; case ConsoleKey.S: case ConsoleKey.DownArrow: command = new MoveDownCommand(); break; case ConsoleKey.A: case ConsoleKey.LeftArrow: command = new MoveLeftCommand(); break; case ConsoleKey.Spacebar: command = new FlyUpCommand(); break; case ConsoleKey.Z: command = new FlyDownCommand(); break; default: Console.WriteLine("IDK that key"); break; } return(command); }