Пример #1
0
 private void mozniPrevzemi2(int y, int x)
 {
     if (po[y, x] == 2)
     {
         if (y > 1 && x > 1)
         {
             if (po[y - 1, x - 1] == 1 || po[y - 1, x - 1] == 3)
             {
                 if (po[y - 2, x - 2] == 0)
                 {
                     Poteza p = new Poteza(true, x - 2, y - 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
         if (y > 1 && x < 8)
         {
             if (po[y - 1, x + 1] == 1 || po[y - 1, x + 1] == 3)
             {
                 if (po[y - 2, x + 2] == 0)
                 {
                     Poteza p = new Poteza(true, x + 2, y - 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
     }
     else if (po[y, x] == 4)
     {
         if (y > 1 && x > 1)
         {
             if (po[y - 1, x - 1] == 1 || po[y - 1, x - 1] == 3)
             {
                 if (po[y - 2, x - 2] == 0)
                 {
                     Poteza p = new Poteza(true, x - 2, y - 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
         if (y > 1 && x < 8)
         {
             if (po[y - 1, x + 1] == 1 || po[y - 1, x + 1] == 3)
             {
                 if (po[y - 2, x + 2] == 0)
                 {
                     Poteza p = new Poteza(true, x + 2, y - 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
         if (y < 8 && x > 1)
         {
             if (po[y + 1, x - 1] == 1 || po[y + 1, x - 1] == 3)
             {
                 if (po[y + 2, x - 2] == 0)
                 {
                     Poteza p = new Poteza(true, x - 2, y + 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
         if (y < 8 && x < 8)
         {
             if (po[y + 1, x + 1] == 1 || po[y + 1, x + 1] == 3)
             {
                 if (po[y + 2, x + 2] == 0)
                 {
                     Poteza p = new Poteza(true, x + 2, y + 2, x, y);
                     poteze2.Add(p);
                 }
             }
         }
     }
 }
Пример #2
0
 public void NarediKoncnoPotezo(Poteza p, int[,] polje)
 {
     if (p.getPreskok())
     {
         polje[(p.getStartY() + p.getY()) / 2, (p.getStartX() + p.getX()) / 2] = 0;
         if (polje[p.getStartY(), p.getStartX()] == 1)
             polje[p.getY(), p.getX()] = 1;
         else if (polje[p.getStartY(), p.getStartX()] == 3)
             polje[p.getY(), p.getX()] = 3;
         polje[p.getStartY(), p.getStartX()] = 0;
     }
     else
     {
         if (polje[p.getStartY(), p.getStartX()] == 1)
             polje[p.getY(), p.getX()] = 1;
         else if (polje[p.getStartY(), p.getStartX()] == 3)
             polje[p.getY(), p.getX()] = 3;
         polje[p.getStartY(), p.getStartX()] = 0;
     }
 }
Пример #3
0
 private void moznePoteze2(int y, int x)
 {
     if (po[y, x] == 2)
     {
         if (x > 0 && y > 0)
         {
             if (po[y - 1, x - 1] == 0)
             {
                 //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                 Poteza p = new Poteza(false, x - 1, y - 1, x, y);
                 poteze2.Add(p);
             }
         }
         if (x < 9 && y > 0)
         {
             if (po[y - 1, x + 1] == 0)
             {
                 //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                 Poteza p = new Poteza(false, x + 1, y - 1, x, y);
                 poteze2.Add(p);
             }
         }
     }
     else if (po[y, x] == 4)
     {
         if (x > 0 && y > 0)
         {
             if (po[y - 1, x - 1] == 0)
             {
                 //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                 Poteza p = new Poteza(false, x - 1, y - 1, x, y);
                 poteze2.Add(p);
             }
         }
         if (x < 9 && y > 0)
         {
             if (po[y - 1, x + 1] == 0)
             {
                 //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                 Poteza p = new Poteza(false, x + 1, y - 1, x, y);
                 poteze2.Add(p);
             }
         }
         if (x > 0 && y < 9)
         {
             if (po[y + 1, x - 1] == 0)
             {
                 //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                 Poteza p = new Poteza(false, x - 1, y + 1, x, y);
                 poteze2.Add(p);
             }
         }
         if (x < 9 && y < 9)
         {
             if (po[y + 1, x + 1] == 0)
             {
                 //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                 Poteza p = new Poteza(false, x + 1, y + 1, x, y);
                 poteze2.Add(p);
             }
         }
     }
 }
Пример #4
0
        private void moznaPoteza2(int y, int x)
        {
            poteze.Clear();
            System.Drawing.Graphics risi;
            risi = Graphics.FromImage(slika);
            SolidBrush blue = new SolidBrush(System.Drawing.Color.Blue);
            if (polje[y, x] == 2)
            {
                if (x > 0 && y > 0)
                {
                    if (polje[y - 1, x - 1] == 0)
                    {
                  //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x - 1, y - 1,x,y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x - 1),  50 * (y - 1), 50, 50);
                    }
                }
                if (x < 9 && y > 0)
                {
                    if (polje[y - 1, x + 1] == 0)
                    {
                    //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x + 1, y - 1,x,y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x + 1),  50 * (y - 1), 50, 50);
                    }
                }
                if (y > 1 && x > 1)
                {
                    if (polje[y - 1, x - 1] == 1 || polje[y - 1, x - 1] == 3)
                    {
                        if (polje[y - 2, x - 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x - 2, y - 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x - 2),  50 * (y - 2), 50, 50);
                        }
                    }
                }
                if(y > 1 && x < 8){
                    if (polje[y - 1, x + 1] == 1 || polje[y - 1, x + 1] == 3)
                    {
                        if (polje[y - 2, x + 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x + 2, y - 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x + 2),  50 * (y - 2), 50, 50);
                        }
                    }
                }
            }
            else if (polje[y, x] == 4)
            {
                if (x > 0 && y > 0)
                {
                    if (polje[y - 1, x - 1] == 0)
                    {
                        //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x - 1, y - 1, x, y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x - 1),  50 * (y - 1), 50, 50);
                    }
                }
                if (x < 9 && y > 0)
                {
                    if (polje[y - 1, x + 1] == 0)
                    {
                        //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x + 1, y - 1, x, y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x + 1),  50 * (y - 1), 50, 50);
                    }
                }
                if (y > 1 && x > 1)
                {
                    if (polje[y - 1, x - 1] == 1 || polje[y - 1, x - 1] == 3)
                    {
                        if (polje[y - 2, x - 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x - 2, y - 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x - 2),  50 * (y - 2), 50, 50);
                        }
                    }
                }
                if (y > 1 && x < 8)
                {
                    if (polje[y - 1, x + 1] == 1 || polje[y - 1, x + 1] == 3)
                    {
                        if (polje[y - 2, x + 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x + 2, y - 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x + 2),  50 * (y - 2), 50, 50);
                        }
                    }
                }
                if (x > 0 && y < 9)
                {
                    if (polje[y + 1, x - 1] == 0)
                    {
                        //      MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x - 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x - 1, y + 1, x, y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x - 1 ),  50 * (y + 1), 50, 50);
                    }
                }
                if (x < 9 && y < 9)
                {
                    if (polje[y + 1, x + 1] == 0)
                    {
                        //    MessageBox.Show("Mozna poteza" + (y - 1) + " " + (x + 1));
                        prvi_klik = true;
                        Poteza p = new Poteza(false, x + 1, y + 1, x, y);
                        poteze.Add(p);
                        risi.FillRectangle(blue,  50 * (x + 1),  50 * (y +1), 50, 50);
                    }
                }
                if (y < 8 && x > 1)
                {
                    if (polje[y + 1, x - 1] == 1 || polje[y + 1, x - 1] == 3)
                    {
                        if (polje[y + 2, x - 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x - 2, y + 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x - 2),  50 * (y + 2), 50, 50);
                        }
                    }
                }
                if (y < 8 && x < 8)
                {
                    if (polje[y + 1, x + 1] == 1 || polje[y + 1, x + 1] == 3)
                    {
                        if (polje[y + 2, x + 2] == 0)
                        {
                            prvi_klik = true;
                            Poteza p = new Poteza(true, x + 2, y + 2, x, y);
                            poteze.Add(p);
                            risi.FillRectangle(blue,  50 * (x + 2),  50 * (y + 2), 50, 50);
                        }
                    }
                }

            }
            pictureBox1.Image = slika;
        }