示例#1
0
        public void Run()
        {
            do
            {
                UserIO.SplashScreen();
                UserIO.WelcomeUser();

                ////Players and Boards

                Player User1 = new Player();
                Player User2 = new Player();
                User1.EnemyPlayer = User2;
                User2.EnemyPlayer = User1;

                UserIO.User1(User1);
                UserIO.DisplayBoard(User1.Board);
                UserIO.PlaceShips(User1.Board);
                UserIO.ClearConsole("Press key and end turn.");

                UserIO.User2(User2);
                UserIO.DisplayBoard(User2.Board);
                UserIO.PlaceShips(User2.Board);
                UserIO.ClearConsole("Press key and end turn");

                UserIO.Randomize(User1, User2);
                UserIO.ClearConsole("Press any key");

                UserIO.TakingTurns(User1, User2);
            }while (UserIO.VictoryAndGlory() == true);
        }
        public void Run()
        {
            Player player1;
            Player player2;
            Board  board1;
            Board  board2;

            do
            {
                //splash screen mehtod
                UserIO.SplashScreen();

                //dec
                player1 = new Player();
                player2 = new Player();
                board1  = new Board();
                board2  = new Board();

                //players will take turns entering name and placing ships
                UserIO.GameSetup(player1, player2, board1, board2);
            } while (Turn.TurnMain(player1, player2, board1, board2) && Turn.PlayAgain() == true);

            Console.WriteLine("Press any key to exit game.");
            Console.ReadKey();
            Environment.Exit(0);
            //display board2 for player1

            //get player1 coords for shot at board2
            //determine result of shot
            //clear
            //prompt and readline to start player 2 turn
            //display board1 for player2
            //get player2 coords for shot at board1
            //determine result of shot
            //clear
            //loop back and forth between players for shots
            //check for victory
            //back to player1 shot
        }
示例#3
0
        public void Run()
        {
            do
            {
                UserIO.SplashScreen();

                Player player1 = new Player();
                Player player2 = new Player();

                UserIO.setUpPlayer(player1);

                UserIO.destroyerPlacement(player1);

                UserIO.submarinePlacement(player1);

                UserIO.cruiserPlacement(player1);

                UserIO.battleshipPlacement(player1);

                UserIO.carrierPlacement(player1);


                UserIO.setUpPlayer(player2);

                UserIO.destroyerPlacement(player2);

                UserIO.submarinePlacement(player2);

                UserIO.cruiserPlacement(player2);

                UserIO.battleshipPlacement(player2);

                UserIO.carrierPlacement(player2);


                UserIO.twoPlayerGame(player1, player2);

                bool play = false;

                do
                {
                    string playAgain = "";

                    Console.WriteLine("Would you like to play again? (1 = Yes, 2 = No)");
                    playAgain = Console.ReadLine();

                    if (playAgain == "2")
                    {
                        Console.WriteLine("Thanks for playing!");
                        Console.WriteLine("Press enter to exit");
                        Console.ReadLine();
                        Environment.Exit(0);
                    }
                    else if (playAgain == "1")
                    {
                        Console.Clear();
                        play = true;
                    }
                } while (play == false);
            } while (true);
        }