Ejemplo n.º 1
0
 private void Panel_Click(object sender, MouseEventArgs me)
 {
     if (game == false)
     {
         if (me.Button == MouseButtons.Left)
         {
             if (Battleships.CheckPlace(x, y, horizontal, vertical, fieldArray1, ref place) == true)
             {
                 Down.Play();
                 Battleships.SetShip(ref fieldArray1, x, y, true, horizontal, vertical);
                 Draw(fieldArray1, ref Field1);
                 if (Battleships.NextShip(ref horizontal, ref vertical, ref shipAmmount) == false)
                 {
                     Battleships.ShootingMode(ref fieldArray1);
                     Battleships.ShootingMode(ref fieldArray2);
                     DrawGame(fieldArray2, ref Field2);
                     Draw(fieldArray1, ref Field1);
                     game = true;
                 }
             }
         }
         else
         {
             Clear(ref Field1);
             Draw(fieldArray1, ref Field1);
             Battleships.Rotate(ref horizontal, ref vertical);
             if (x + horizontal > 9)
             {
                 x = 6;
             }
             if (y + vertical > 9)
             {
                 y = 6;
             }
             DrawShip(horizontal, vertical, fieldArray1, ref Field1, x, y);
         }
     }
     else
     {
         if (turn == true)
         {
             for (int i = 0; i < 10; i++)
             {
                 for (int j = 0; j < 10; j++)
                 {
                     if (Field2[i, j] == sender)
                     {
                         Shoot(i, j, ref fieldArray2, ref Field2);
                     }
                 }
             }
         }
     }
 }