Ejemplo n.º 1
0
        public Controller()
        {
            Parser    = new Parser();
            InputView = new InputView();

            OutputView = new OutputView();
            OutputView.DisplayMenu();

            while (true)
            {
                ConsoleKeyInfo input = InputView.WaitForInput();
                if (input.Key != ConsoleKey.S)
                {
                    int.TryParse(input.KeyChar.ToString(), out int number);
                    if (number >= 1 && number <= 6)
                    {
                        CurrentMaze = number;
                        break;
                    }
                }
                else
                {
                    return;
                }
            }

            Maze = Parser.ParseMaze(CurrentMaze);
            Start();
        }
Ejemplo n.º 2
0
        private void Start()
        {
            while (true)
            {
                DisplayMaze();

                ConsoleKeyInfo input = InputView.WaitForInput();

                switch (input.Key)
                {
                case ConsoleKey.S:
                    return;

                case ConsoleKey.R:
                    Maze = Parser.ParseMaze(CurrentMaze);
                    break;

                case ConsoleKey.UpArrow:
                    Maze.Forklift.Move(Dir.UP);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.RightArrow:
                    Maze.Forklift.Move(Dir.RIGHT);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.DownArrow:
                    Maze.Forklift.Move(Dir.DOWN);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.LeftArrow:
                    Maze.Forklift.Move(Dir.LEFT);
                    Maze.Employee.DoSomething();
                    break;
                }

                if (CheckWin())
                {
                    break;
                }
            }

            OutputView.DisplayVictory();
            Console.ReadKey();
        }