Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Ship     skib     = new Ship(5);
            PlayArea playArea = new PlayArea();

            playArea.GenerateArea();
            playArea.PlaceShip(4, 1, skib, true);
            CreatePlayerArea(playArea);
            Console.WriteLine("");
            Console.ReadLine();
        }
Exemplo n.º 2
0
 public static void CreateEnemyArea(PlayArea enemyarea)
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             if (enemyarea.EnemyFields[i, j].Taken)
             {
                 enemyarea.EnemyFields[i, j].ShipHit();
                 Console.Write($"[(XX)]");
             }
             else
             {
                 Console.Write($"[({enemyarea.EnemyFields[i, j].ColumnNumber}|{enemyarea.EnemyFields[i, j].RowNumber})]");
             }
         }
         Console.Write($"\n");
     }
 }
Exemplo n.º 3
0
 public static void CreatePlayerArea(PlayArea playArea)
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             if (playArea.Fields[i, j].Taken)
             {
                 playArea.Fields[i, j].ShipHit();
                 Console.Write($"[(O)]");
             }
             else
             {
                 Console.Write($"[({playArea.Fields[i,j].ColumnNumber}|{playArea.Fields[i,j].RowNumber})]");
             }
         }
         Console.Write($"\n");
     }
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            PlayArea         playArea  = new PlayArea();
            PlayArea         enemyArea = new PlayArea();
            RandomShipPlacer placer    = new RandomShipPlacer();

            playArea.GenerateArea();
            enemyArea.GenerateArea();
            enemyArea.GenerateEnemyShips();
            CreatePlayerArea(playArea);
            Console.WriteLine(" ");
            placer.PlaceShip(enemyArea.EnemyShips, 0, enemyArea.EnemyFields);
            Console.ReadLine();
            placer.PlaceShip(enemyArea.EnemyShips, 1, enemyArea.EnemyFields);
            Console.ReadLine();
            placer.PlaceShip(enemyArea.EnemyShips, 2, enemyArea.EnemyFields);
            Console.ReadLine();
            placer.PlaceShip(enemyArea.EnemyShips, 3, enemyArea.EnemyFields);
            Console.ReadLine();
            placer.PlaceShip(enemyArea.EnemyShips, 4, enemyArea.EnemyFields);
            CreateEnemyArea(enemyArea);
            Console.WriteLine("");
            Console.ReadLine();
        }