Main() private static method

private static Main ( Array args ) : void
args Array
return void
Example #1
0
        private void AskUserForRestart()
        {
            int leftX = this.wall.LeftX + 1;
            int topY  = 3;

            Console.SetCursorPosition(leftX, 0);
            Console.WriteLine($"Player points: {snake.PlayerPoints}");

            Console.SetCursorPosition(leftX, 1);
            Console.WriteLine($"Player level: {snake.PlayerLevel}");

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n -> ");
            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                this.StopGame();
            }
        }
Example #2
0
        public void AskUserForRestart()
        {
            int leftX = wall.LeftX + 1;
            int topY  = 3;

            Console.SetCursorPosition(leftX + 2, topY - 2);
            Console.Write($"Player points: {Progress.Points}");
            Console.SetCursorPosition(leftX + 2, topY - 1);
            Console.Write($"Player level: {Progress.Level}");

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n -> ");

            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #3
0
        public void Run()
        {
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    GetNexDirection();
                }

                var cnaMove = this.snake.isMoving(this.directionpoints[(int)this.direction]);

                if (!cnaMove)
                {
                    File.AppendAllText("../../../DataBase/scores.txt", $"Yavor - {this.snake.Lenght} - {DateTime.Now:d}{Environment.NewLine}");
                    var rsults = File.ReadAllText("../../../DataBase/scores.txt");

                    Console.SetCursorPosition(0, this.wall.TopY + 2);
                    Console.WriteLine(rsults);
                    Console.WriteLine("Oh nooooo");
                    Thread.Sleep(2000);
                    StartUp.Main();
                }
                Thread.Sleep(sleepTime);
            }
        }
Example #4
0
        private void AskUserForRestart()
        {
            int row = 7;
            int col = 5;

            Write("Would you like", row, col);

            col += 4;
            row++;
            Write("to continue?", row, col);

            col += 2;
            row++;
            Write("Y/N", row, col);

            Console.SetCursorPosition(col, row + 1);
            string input = Console.ReadLine();

            if (input.ToLower() == "y")
            {
                SaveScore();
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #5
0
        private void AskPlayerForRestart()
        {
            int x = GameConstant.Config.EndMessageX;
            int y = GameConstant.Config.EndMessageY;

            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Would you like to continue?");

            Console.SetCursorPosition(x + 12, y + 1);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Y/N");

            var input = Console.ReadKey();

            //TODO fix exception when N
            if (input.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                return;
            }
        }
Example #6
0
        private void AskUserForRestart()
        {
            Console.SetCursorPosition(110, 15);
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.Write("Would you like to play again? ");
            Console.Write("Y/N: ");
            string input = Console.ReadLine();

            if (input.ToLower() == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #7
0
        private void AskUserForRestart()
        {
            Console.SetCursorPosition(12, 5);
            Console.Write("Would you like to continue? y/n ");


            ConsoleKeyInfo userInput = Console.ReadKey();

            if (userInput.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #8
0
        private void AskToPlayAgain()
        {
            Console.Clear();
            Console.SetCursorPosition(0, 0);

            Console.WriteLine("Do you want to play again? y-yes/n-no");

            string answer = Console.ReadLine().ToLower();

            if (answer == "y" || answer == "yes")
            {
                StartUp.Main();
            }
            else if (answer == "n" || answer == "no")
            {
                Environment.Exit(0);
            }
        }
Example #9
0
        private void RestartGame()
        {
            Console.SetCursorPosition(GameData.Config.endMessageX, GameData.Config.endMessageY);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(GameData.Config.endMessage);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("Y/N");

            var input = Console.ReadKey();

            if (input.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }

            Environment.Exit(0);
        }
Example #10
0
        private void AskUserForRestart()
        {
            int HX = this.wall.HorX + 1;
            int VY = 3;

            Console.SetCursorPosition(HX, VY);
            Console.WriteLine("Would you like to continue? y/n");
            string input = Console.ReadLine();

            if (input.ToLower() == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #11
0
        private void AskUserForRestart()
        {
            int leftX = this.wall.LeftX + 3;
            int topY  = 3;

            Console.SetCursorPosition(leftX, topY);
            Console.Write($"Would you like to continue? y/n");
            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #12
0
        private void AskUserForRestart()
        {
            int leftX = Console.WindowWidth / 2;
            int topY  = Console.WindowHeight / 2;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("WOULD YOU LIKE TO RESTART? Y/N => ");

            string input = Console.ReadLine();

            if (input.ToLower() == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
        private void AskUserForRestart()
        {
            var leftX = this.wall.LeftX + 1;
            var topY  = 3;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? yes/no");
            Console.SetCursorPosition(leftX, topY + 1);

            var input = Console.ReadLine().ToLower();

            if (input == "yes")
            {
                StartUp.Main();
            }
            else if (input == "no")
            {
                this.StopGame();
            }
        }
Example #14
0
        private void AskUserForRestart()
        {
            int leftX = this.wall.LeftX + 2;
            int topY  = 3;

            Console.SetCursorPosition(leftX, topY);
            Console.WriteLine("Would you like to continue? y / n");

            string input = Console.ReadLine();

            if (input.Equals("y"))
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #15
0
        private void AskUserForRestart()
        {
            int leftX = this.wall.LeftX + 4;
            int topY  = 6;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue> YES/NO? ");

            string input = Console.ReadLine().ToLower();

            if (input == "yes")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #16
0
        private void AskUserForRestart()
        {
            int leftX = Console.WindowWidth / 2;
            int topY  = Console.WindowHeight / 2;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n");

            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #17
0
        private void AskPlayerForRestart()
        {
            int x = 45;
            int y = 20;

            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Would you like to continue? y/n");

            var input = Console.ReadKey();

            if (input.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }
            else if (input.Key == ConsoleKey.N)
            {
                StopGame();
            }
        }
Example #18
0
        private void AskUserForRestart()
        {
            this.ShowBestScore();

            var leftX = this.wall.LeftX / 2;
            var topY  = this.wall.TopY / 2;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n");

            var input = Console.ReadLine();

            if (input == "y" || input == "Y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                this.StopGame();
            }
        }
Example #19
0
        private void AskUserForRestart()
        {
            int leftX = this.wallInfo.LeftX + 2;
            int topY  = 6;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n");
            Console.SetCursorPosition(leftX, topY + 1);
            Console.Write("Your choice: ");

            string input = Console.ReadKey().KeyChar.ToString().ToLower();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else if (input == "n")
            {
                StopGame();
            }
        }
Example #20
0
        private void AskPlayerForRestart()
        {
            int x = 45;
            int y = 20;

            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Would you like to continue: ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("Y/N");

            string input = Console.ReadLine();

            if (input.ToLower() == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #21
0
        private void AskPlayerForRestart()
        {
            Console.SetCursorPosition(GameConstant.Config.EndMessageX, GameConstant.Config.EndMessageY);

            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Would you like to continue? ");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Y/N");

            var input = Console.ReadKey();

            if (input.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Console.Clear();
                System.Environment.Exit(1);
            }
        }
Example #22
0
        public static void AskUserForRestart()
        {
            int x = 45;
            int y = 20;

            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("Would you like to continue ? ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Y/N");

            string input = Console.ReadLine();

            if (input == "Y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #23
0
        public void AskForRestart()
        {
            int leftX = this.wall.LeftX + 3;
            int topY  = 10;

            Console.SetCursorPosition(leftX, topY);
            Console.Write("Would you like to continue? y/n");

            Console.SetCursorPosition(leftX, topY + 2);
            Console.Write("Your choise is: ");

            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                StopGame();
            }
        }
Example #24
0
        private void ResterPlayer()
        {
            int x = 45;
            int y = 20;

            Console.SetCursorPosition(x, y);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(GameConstants.Player.RestertAsk);
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.Write(GameConstants.Player.RestertAnswer);

            var input = Console.ReadKey();

            if (input.Key == ConsoleKey.Y)
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Example #25
0
        private void AskUserForRestart()
        {
            int leftX = Console.WindowWidth / 3;
            int topY  = Console.WindowHeight / 2;

            Console.SetCursorPosition(leftX, topY);
            Console.Write($"Player points: {this.snake.snakeElements.Count} ");
            Console.Write("Would you like to continue? y/n");

            string input = Console.ReadLine();

            if (input == "y")
            {
                Console.Clear();
                StartUp.Main();
            }
            else
            {
                Console.SetCursorPosition(leftX, topY);
                Console.Write("Game Over! ");
                Environment.Exit(0);
            }
        }