示例#1
0
        private void PlayGame(int i)
        {
            Game = new Game();
            var loaded = Game.LoadMaze(i);

            if (!loaded)
            {
                return;
            }

            var arrows = new[] { ConsoleKey.UpArrow, ConsoleKey.DownArrow, ConsoleKey.LeftArrow, ConsoleKey.RightArrow };

            while (Game.IsPlaying)
            {
                LevelView.PrintView(Game.GetMap());
                var input = AskInput();

                if (input == ConsoleKey.S)
                {
                    return;
                }

                if (input == ConsoleKey.R)
                {
                    Game.LoadMaze(i);
                }

                if (arrows.Contains(input))
                {
                    Game.MoveForklift(input);
                }
            }
            if (!Game.IsGameOver)
            {
                ResultView.PrintView();
            }
            else
            {
                GameOverView.PrintView();
            }
            Console.ReadKey();
        }