Esempio n. 1
0
 private static void Main()
 {
     using (var game = new SokobanGame())
     {
         game.Run();
     }
 }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var lines = File.ReadAllLines(@"Resources\Levels\level0.txt");
            var level = LevelParser.Parse(lines);
            var game  = new SokobanGame(level);

            while (true)
            {
                Console.Clear();
                Display(game.Level);

                if (game.HasWon())
                {
                    Console.WriteLine("\nYou won!\n");
                    return;
                }

                Console.WriteLine("\nWASD or arrow keys to move\nEsc to exit");

                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.Escape:
                    return;

                case ConsoleKey.W:
                case ConsoleKey.UpArrow:
                    game.MovePlayer(Direction.North);
                    break;

                case ConsoleKey.D:
                case ConsoleKey.RightArrow:
                    game.MovePlayer(Direction.East);
                    break;

                case ConsoleKey.S:
                case ConsoleKey.DownArrow:
                    game.MovePlayer(Direction.South);
                    break;

                case ConsoleKey.A:
                case ConsoleKey.LeftArrow:
                    game.MovePlayer(Direction.West);
                    break;
                }
            }
        }