Пример #1
0
        public static void EndGame(ArgumentException ae)
        {
            Hero.RemoveHero();
            Timers.TimerStop();
            Timers.TimerDispose();

            if (ae.Message == "On map? False")
            {
                WriteAt("You have hit the border", 0, 12);
                WriteAt("Press any key to exit", 0, 13);
            }
            else
            {
                WriteAt("You have hit the ESC key", 0, 12);
                WriteAt("Press any key to exit", 0, 13);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            World.InitGame();

            ConsoleKeyInfo keyInfo;

            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Escape)
            {
                try
                {
                    switch (keyInfo.Key)
                    {
                    case ConsoleKey.RightArrow:
                        Hero.MoveHero(1, 0);
                        break;

                    case ConsoleKey.LeftArrow:
                        Hero.MoveHero(-1, 0);
                        break;

                    case ConsoleKey.DownArrow:
                        Timers.TimerStop();
                        Hero.MoveHero(0, 1);
                        Timers.TimerStart();
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    World.EndGame(ae);
                    break;
                }
            }

            Console.ReadKey();
        }