示例#1
0
        public static void Menu()
        {
            var check = true;

            while (check)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("1 - New game!");
                Console.WriteLine("2 - Best results!");
                Console.WriteLine("3 - Exit game!");
                var point = Console.ReadKey();
                switch (point.Key)
                {
                case ConsoleKey.D1:
                    Console.Clear();
                    var game = new Game();
                    game.NewGame();
                    break;

                case ConsoleKey.D2:
                    Console.Clear();
                    BestResult.ViewResults(10);
                    break;

                case ConsoleKey.D3:
                    check = false;
                    return;

                default:
                    Console.Clear();
                    break;
                }
            }
        }
示例#2
0
        static void MenuLogic()
        {
            int            pos  = 0;
            bool           exit = false;
            ConsoleKeyInfo btn  = new ConsoleKeyInfo();

            while (!exit)
            {
                if (pos > 4)
                {
                    pos = 0;
                }
                if (pos < 0)
                {
                    pos = 4;
                }
                ShowMenu(pos);

                btn = Console.ReadKey();

                if (btn.Key == ConsoleKey.UpArrow)
                {
                    pos--;
                }
                if (btn.Key == ConsoleKey.DownArrow)
                {
                    pos++;
                }
                if (btn.Key == ConsoleKey.Enter)
                {
                    switch (pos)
                    {
                    case 0:
                        Game.NewGame();
                        GameProcess();
                        break;

                    case 1:
                        Game.btn   = new ConsoleKeyInfo();
                        Game.check = true;
                        GameProcess();
                        break;

                    case 2:
                        UsersLogic();
                        break;

                    case 3:
                        Game.SaveDataGame(true);
                        break;

                    case 4:
                        exit = true;
                        break;
                    }
                }
            }
        }
示例#3
0
 public static bool GameOver()
 {
     if (Collision(snake.body[0]))
     {
         Game.NewGame();
         return(true);
     }
     return(false);
 }
示例#4
0
        static void Main(string[] args)
        {
            Game.NewGame();
            int x = Game.sizex;
            int y = Game.sizey;

            Console.CursorVisible = false;
            Console.SetWindowSize(x, y);
            //          Game.Draw();
            //            Console.ReadKey();
            //GameProcess();
            MenuLogic();
        }