Пример #1
0
        private static void Main(string[] args)
        {
            //Setting game colors.
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Clear();

            GameFlow gf = new GameFlow();
            StartMenu sm = new StartMenu();
            //Player player1;
            //Player player2;

            sm.DisplayStart();
            Console.Clear();

            Console.WriteLine("{0}, press enter to start placing ships.\n\n{1} LOOK AWAY!!", Player.Name1,
                Player.Name2);
            Console.ReadLine();
            Console.Clear();

            gf.Player1ShipPlacement();
            Console.Clear();

            Console.WriteLine("{0}, press enter to start placing ships.\n\n{1} LOOK AWAY!!", Player.Name2,
                Player.Name1);
            Console.ReadLine();
            Console.Clear();

            gf.Player2ShipPlacement();
            Console.Clear();

            gf.GamePlay();

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            SetupFlow setUp = new SetupFlow();
            //setUp.SetUp();

            GameFlow playGame = setUp.SetUp();

            playGame.PlayTheGame();
            Console.ReadKey();
        }
Пример #3
0
        public void setupGame()
        {
            //display splashscreen
            ConsoleOutput.DisplayTitle();

            //collect player names and store them
            p1Name = ConsoleInput.P1EnterName();
            p2Name = ConsoleInput.P2EnterName();

            //player 1 setup your board
            ConsoleOutput.PlaceYourShips(p1Name);
            Board p1Board = new Board();

            p1Board = BoardSetup.BuildBoard(p1Board);
            //player 2 setup your board
            ConsoleOutput.PlaceYourShips(p2Name);
            Board p2Board = new Board();

            p2Board = BoardSetup.BuildBoard(p2Board);

            Player PlayerOne = new Player(p1Name, p1Board);
            Player PlayerTwo = new Player(p2Name, p2Board);

            //determine who goes first randomly
            bool IsPlayer1sTurn = DecideWhoGoesFirst();

            bool DecideWhoGoesFirst()
            {
                return(RNG.CoinFlip());
            }

            //set the game state and call gameflow method
            GameState Current = new GameState(PlayerOne, PlayerTwo, IsPlayer1sTurn);

            //loop back until victory
            while (!GameFlow.GameOver)
            {
                if (IsPlayer1sTurn)
                {
                    ConsoleOutput.DrawActiveBoard(p2Board);
                    GameFlow p1 = new GameFlow(PlayerOne, PlayerTwo);
                    IsPlayer1sTurn = false;
                }
                else
                {
                    ConsoleOutput.DrawActiveBoard(p1Board);
                    GameFlow p2 = new GameFlow(PlayerTwo, PlayerOne);
                    IsPlayer1sTurn = true;
                }
            }
        }
Пример #4
0
        public static void replay()
        {
            Console.WriteLine("Would you like to play again?  Yes or no ");
            string answer = ConsoleInput.ReadLine();

            if (answer == "Yes" || answer == "yes" || answer == "Y" || answer == "y")
            {
                GameFlow.Flow();
            }
            else
            {
                Console.WriteLine("Thanks for playing!, press any key to quit");
                Console.ReadKey();
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            while (true)
            {
                GameFlow newGame = new GameFlow();

                newGame.RunGame();

                Console.WriteLine("Would you like to play again ?");
                var keepGoing = Console.ReadLine().ToLower();
                if (keepGoing[0] != 'y')
                {
                    break;
                }
            }
        }
Пример #6
0
 static void Main(string[] args)
 {
     //initiate start game
     while (true)
     {
         GameSetup game = new GameSetup();
         game.setupGame();
         bool Again = GameFlow.PlayAgain();
         if (true && (Again))
         {
             GameSetup newGame = new GameSetup();
             newGame.setupGame();
         }
         else
         {
             break;
         }
     }
 }
Пример #7
0
        public static Ship[] PlaceShipTest2(Board x)

        {
            for (int k = 0; k < 5; k++)
            {
                bool             repeat     = true;
                PlaceShipRequest NewRequest = new PlaceShipRequest();
                do
                {
                    NewRequest = GameFlow.Request(x, k);


                    x.CheckCoordinate(NewRequest.Coordinate);


                    ShipPlacement Test = new ShipPlacement();

                    Test = x.PlaceShip(NewRequest);

                    if (Test == ShipPlacement.Overlap)
                    {
                        repeat = true;
                        Console.WriteLine("Oops, there was an overlap, let's try that again");
                    }
                    else if (Test == ShipPlacement.NotEnoughSpace)
                    {
                        repeat = true;
                        Console.WriteLine("No room there, try again");
                    }
                    else if (Test == ShipPlacement.Ok)
                    {
                        repeat = false;
                        Console.WriteLine("That works!");
                    }
                }while (repeat == true);
            }
            return(x.Ships);
        }
        static void Main(string[] args)
        {
            GameFlow game = new GameFlow();

            game.Play();
        }
Пример #9
0
        static void Main(string[] args)
        {
            GameFlow game = new GameFlow();

            game.GameStart();
        }
Пример #10
0
        static void Main(string[] args)
        {
            GameFlow g = new GameFlow();

            g.Run();
        }
Пример #11
0
        static void Main(string[] args)
        {
            GameFlow Game = new GameFlow();

            GameFlow.Flow();
        }
Пример #12
0
        static void Main(string[] args)
        {
            GameFlow flow = new GameFlow();

            flow.Start();
        }
Пример #13
0
        public static void Flow()
        {
            Output.WelcomeMessage();
            P1_Name = Output.P1_name();
            P2_Name = Output.P2_name();

            //p1 Build Board

            Make.Blank(p1_Board);
            Output.PlayerTurn(P1_Name);
            Console.WriteLine("");
            GameFlow.PlaceShipTest2(p1_Board);
            Make.Drawboard(p1_Board);
            Console.ReadKey();
            Console.Clear();

            //p2 Build Board
            Make.Blank(p2_Board);
            Output.PlayerTurn(P2_Name);
            Console.WriteLine("");
            GameFlow.PlaceShipTest2(p2_Board);
            Make.Drawboard(p2_Board);
            Console.ReadKey();
            Console.Clear();

            Random _Rnd = new Random();
            int    turn = _Rnd.Next(1, 2);

            ShotStatus Victorious = new ShotStatus();

            Console.WriteLine("Let the Games begin!");

            do
            {
                if (turn % 2 == 0)
                {
                    Console.Clear();
                    bool repeat = false;
                    Console.WriteLine($"It's {P2_Name}'s turn");
                    //player 2 goes first
                    Console.WriteLine($"{P2_Name}'s Board");
                    Make.Drawboard(p2_Board);
                    Console.WriteLine($"{P1_Name}'s Board");
                    Make.DrawEnemyBoard(p1_Board);

                    do
                    {
                        Console.WriteLine("Pick Somewhere to Fire");


                        Coordinate       FireCord            = (ConsoleInput.InputtoCoordinate());
                        FireShotResponse p2_ResponseOfChoice = p1_Board.FireShot(FireCord);

                        if (p2_ResponseOfChoice.ShotStatus == ShotStatus.Duplicate)
                        {
                            Console.WriteLine("You already tried that silly!, try again!");
                            repeat = true;
                        }
                        else if (p2_ResponseOfChoice.ShotStatus == ShotStatus.Hit)
                        {
                            Console.WriteLine("It's a hit!");
                            Make.DrawEnemyBoardFire(p1_Board, p2_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p2_ResponseOfChoice.ShotStatus == ShotStatus.HitAndSunk)
                        {
                            Console.WriteLine($"Massive hit!, You sunk the {p2_ResponseOfChoice.ShipImpacted}");
                            Make.DrawEnemyBoardFire(p1_Board, p2_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p2_ResponseOfChoice.ShotStatus == ShotStatus.Invalid)
                        {
                            Console.WriteLine("Invalid input, try again");
                            repeat = true;
                        }
                        else if (p2_ResponseOfChoice.ShotStatus == ShotStatus.Miss)
                        {
                            Console.WriteLine("Oops, looks like you missed");
                            Make.DrawEnemyBoardFire(p1_Board, p2_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p2_ResponseOfChoice.ShotStatus == ShotStatus.Victory)
                        {
                            Console.WriteLine($"{P2_Name} Wins!");
                            Victorious = ShotStatus.Victory;
                            repeat     = false;
                        }
                    } while (repeat == true);

                    Console.ReadKey();
                    turn++;
                }
                else
                {
                    Console.Clear();
                    bool repeat = false;
                    //player 1 goes first
                    Console.WriteLine($"{P1_Name}'s turn");
                    Console.WriteLine($"{P1_Name}'s Board");
                    Make.Drawboard(p1_Board);
                    Console.WriteLine($"{P2_Name}'s Board");
                    Make.DrawEnemyBoard(p2_Board);

                    //player 1 goes first
                    do
                    {
                        Console.WriteLine("Pick Somewhere to Fire");



                        Coordinate       FireCord            = (ConsoleInput.InputtoCoordinate());
                        FireShotResponse p1_ResponseOfChoice = p2_Board.FireShot(FireCord);

                        if (p1_ResponseOfChoice.ShotStatus == ShotStatus.Duplicate)
                        {
                            Console.WriteLine("You already tried that silly!, try again!");
                            repeat = true;
                        }
                        else if (p1_ResponseOfChoice.ShotStatus == ShotStatus.Hit)
                        {
                            Console.WriteLine("It's a hit!");
                            Make.DrawEnemyBoardFire(p2_Board, p1_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p1_ResponseOfChoice.ShotStatus == ShotStatus.HitAndSunk)
                        {
                            Console.WriteLine($"Massive hit!, You sunk the {p1_ResponseOfChoice.ShipImpacted}");
                            Make.DrawEnemyBoardFire(p2_Board, p1_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p1_ResponseOfChoice.ShotStatus == ShotStatus.Invalid)
                        {
                            Console.WriteLine("Invalid input, try again");
                            repeat = true;
                        }
                        else if (p1_ResponseOfChoice.ShotStatus == ShotStatus.Miss)
                        {
                            Console.WriteLine("Oops, looks like you missed");
                            Make.DrawEnemyBoardFire(p2_Board, p1_ResponseOfChoice, FireCord);
                            repeat = false;
                        }
                        else if (p1_ResponseOfChoice.ShotStatus == ShotStatus.Victory)
                        {
                            Console.WriteLine($"{P1_Name} Wins!");
                            Victorious = ShotStatus.Victory;
                            repeat     = false;
                        }
                    }while (repeat == true);
                    Console.ReadKey();
                    turn++;
                }
            } while (Victorious != ShotStatus.Victory);

            Output.replay();


            Console.ReadKey();
            Console.Clear();
        }
Пример #14
0
        static void Main(string[] args)
        {
            GameFlow battleship = new GameFlow();

            battleship.PlayGame();
        }