Ejemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     label1.BackColor = Color.Transparent;
     label1.Text      = "Шашек на поле:";
     label2.BackColor = Color.Transparent;
     label3.BackColor = Color.Transparent;
     //Размещение шашек
     for (int k = 0; k < a; k++)
     {
         if (k % 2 == 0)
         {
             Pct_left = 100;
         }
         else
         {
             Pct_left = 50;
         }
         for (int i = 0; i < b; i++)
         {
             Pct_array[k, i] = new MyPictureBox(startID, Pct_top, Pct_left, Pct_width, Pct_heigh)
             {
                 Parent = this
             };
             if (startID < 12)
             {
                 field[k, i] = 1;              //черная шашка
             }
             if ((startID >= 12) && (startID < 20))
             {
                 field[k, i] = 0;                                   //пустое
             }
             if (startID > 19)
             {
                 field[k, i] = 3;              //белая шашка
             }
             Pct_left = Pct_left + 100;
             startID++;
             Pct_array[k, i].MouseClick += this.Click_pb;
             Pct_array[k, i].MouseUp    += this.Up_pb;
         }
         Pct_top = Pct_top + 50;
     }
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             if (field[i, j] == 1 || field[i, j] == 2)
             {
                 Black++;
             }
             if (field[i, j] == 3 || field[i, j] == 4)
             {
                 White++;
             }
         }
     }
     label2.Text  = "Чёрных: " + Black.ToString();
     label2.Text += "\nБелых: " + White.ToString();
     label3.Text  = "Ход Белых";
 }
Ejemplo n.º 2
0
        void Click_pb(object sender, System.EventArgs e)
        {
            MyPictureBox picture = sender as MyPictureBox;

            for (int i = 0; i < 8; i++) //Обнуление возможных полей для хода
            {
                for (int j = 0; j < 4; j++)
                {
                    if (field[i, j] == 0)
                    {
                        Pct_array[i, j].Image = Properties.Resources.Клетка;
                    }
                    Pct_array[i, j].Pressed = false;
                }
            }
            if (picture.Pressed == false)
            {
                ID1 = picture.IDPictureBox;//рабочая переменная (укорачивает запись)
                if (stroke)
                {
                    if (field[ID1 / b, ID1 % b] == 3)
                    {
                        coursel_sr();
                        if (srub && turn_sr)
                        {
                            coursel_w();
                        }
                    }
                    if ((field[IDID / b, IDID % b] == 3) && l && (field[ID1 / b, ID1 % b] == 0))
                    {
                        if (srub && turn_sr)
                        {
                            corse_simple();
                        }
                        else
                        {
                            course_srub();
                        }
                    }
                }
                else
                {
                    if (field[ID1 / b, ID1 % b] == 1)
                    {
                        coursel_sr();
                        if (srub && turn_sr)
                        {
                            coursel_b();
                        }
                    }
                    if ((field[IDID / b, IDID % b] == 1) && l && (field[ID1 / b, ID1 % b] == 0))
                    {
                        if (srub && turn_sr)
                        {
                            corse_simple();
                        }
                        else
                        {
                            course_srub();
                        }
                    }
                }
                picture.Pressed = true;
            }
        }