Esempio n. 1
0
 private void pb_up_p1_MouseDown(object sender, MouseEventArgs e)
 {
     if (turns_p1 >= 1)
     {
         if (checkshots == 0)
         {
             int k = 0, l = 0;
             int counti = 0, countj = 0, countid = 0;
             for (int i = 0; i <= e.X; i += 33)
             {
                 counti++;
                 for (int j = 0; j <= e.Y; j += 33)
                 {
                     countj++;
                     k = i;
                     l = j;
                 }
             }
             countj  = countj / counti;
             countid = counti * 6 - (6 - countj);
             shots_p1++;
             Squareup squareP1ship = new Squareup(countid, k, l);
             if (l_up_p1.ElementAt(countid - 1).shot == false)
             {
                 foreach (Squareup squ in l_up_p1)
                 {
                     if (squ.id == squareP1ship.id && squ.full == true)
                     {
                         hits_p1++;
                         squareP1ship.FillH(gup);
                         l_up_p1.Where(w => w.id == countid).ToList().ForEach(s => s.shot = true);
                         break;
                     }
                     else
                     {
                         squareP1ship.FillM(gup);
                         l_up_p1.Where(w => w.id == countid).ToList().ForEach(s => s.shot = true);
                     }
                 }
                 checkshots = 1;
             }
             else
             {
                 checkshots = 0;
                 shots_p1--;
                 MessageBox.Show("You already shot at that place. Try another one.");
             }
         }
         else
         {
             MessageBox.Show("You already shot, click Continue to move on.");
         }
     }
     else
     {
         MessageBox.Show("Wait for other player to place ships.");
     }
 }
Esempio n. 2
0
 public void InitializeP2ships() //gornji mali
 {
     for (int i = 0; i < 132; i += 33)
     {
         for (int j = 0; j < 165; j += 33)
         {
             Squareup squareP2ships = new Squareup(count_P2ships, i, j);
             l_P2ships.Add(squareP2ships);
             count_P2ships++;
         }
     }
 }
Esempio n. 3
0
 public void Initializepbup() //gornji veliki
 {
     for (int i = 0; i < 396; i += 33)
     {
         for (int j = 0; j < 198; j += 33)
         {
             Squareup squareup = new Squareup(count_up_p1, i, j);
             l_up_p1.Add(squareup);
             count_up_p1++;
         }
     }
 }