Exemple #1
0
 private void SetStandardShips()
 {
     MyGame.GameShips = new List <Ship>()
     {
         new Ship(5),
         new Ship(4),
         new Ship(3),
         new Ship(2),
         new Ship(1)
     };
     ShipPlacementMenu.RunMenu();
 }
Exemple #2
0
        private void ChangeShipsCount()
        {
            int input;

            do
            {
                Console.Clear();
                input = ConsoleView.IntegerInputHelper("ships", MyGame.NumberOfShips);
                if (input > MyGame.Rows && input > MyGame.Cols)
                {
                    Console.WriteLine("There cannot be more ships than there are rows and columns on board!");
                    ConsoleView.WaitForUser();
                    continue;
                }
                break;
            } while (true);

            MyGame.NumberOfShips = input;
            Console.WriteLine($"No of ships set to: {MyGame.NumberOfShips}");
            ConsoleView.WaitForUser();
            MyGame.GameShips = new List <Ship>();

            for (int i = 1; i <= MyGame.NumberOfShips; i++)
            {
                Console.Clear();
                Console.Write($"Enter size of {i}. ship: ");
                do
                {
                    input = ConsoleView.IntegerInputHelper("ship size", MyGame.NumberOfShips);
                    if (input > MyGame.Cols && input > MyGame.Rows)
                    {
                        Console.WriteLine("Ship cannot be bigger than board!\nPlease try again:");
                        continue;
                    }
                    break;
                } while (true);
                MyGame.GameShips.Add(new Ship(input));
            }
            ShipPlacementMenu.RunMenu();
        }