Exemple #1
0
        private void check_numofplayerballs(player p1, player p2)
        {
            if (decideplayer % 2 == 0)
            {
                tb.Text = "RED CHANCE...";

            }
            else
            {
                tb.Text = "YELLOW CHANCE...";
            }
            int p1_sum = 0, p2_sum = 0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    p1_sum += p1.pos[i, j];
                    p2_sum += p2.pos[i, j];
                }
            }
            if (p1_sum == 0)
            { tb.Text = "yellow wins";
            this.Frame.Navigate(typeof(winner), tb.Text);
            }
            else if (p2_sum == 0)
            {
                tb.Text = "red wins ";
                this.Frame.Navigate(typeof(winner), tb.Text);
            }
        }
Exemple #2
0
 private bool checkif_notoccupied(player p, player op, int x, int y)
 {
     if (op.pos[x, y] == 0)
         return true;
     else
         return false;
 }
Exemple #3
0
        private void blast(object sender, player p, player op, int num_ways, int x, int y)
        {
            bleep.Play();
            var brush = new ImageBrush();
            if (x - 1 >= 0)
            {
                if (op.pos[x - 1, y] > 0)
                {
                    p.pos[x - 1, y] = op.pos[x - 1, y] + 1;

                }
                else
                {
                    p.pos[x - 1, y] = 1;
                    // check(sender, p, op, x - 1, y);
                }

                //
                var brush1 = new ImageBrush();
                if (decideplayer % 2 == 0)
                {//current player red

                    if (p.pos[x - 1, y] == 1)
                    {

                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                    }
                    else if (p.pos[x - 1, y] == 2)
                    {
                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                    }

                    else if (p.pos[x - 1, y] == 3)
                    {
                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                    }

                }
                else
                {

                    if (p.pos[x - 1, y] == 1)
                    {
                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                    }
                    else if (p.pos[x - 1, y] == 2)
                    {
                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                    }

                    else if (p.pos[x - 1, y] == 3)
                    {
                        brush1.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));

                    }

                }
                Button bn = b[x - 1, y];
                bn.Background = brush1;

                if (num_ways == 4 && op.pos[x - 1, y] == 3)
                {
                    p.pos[x - 1, y] = 3;
                    check(sender, p, op, x - 1, y);

                }
                else if (num_ways == 3 && op.pos[x - 1, y] == 2)
                {
                    tb.Text = " " + p.pos[x - 1, y];
                    p.pos[x - 1, y] = 2;
                    check(sender, p, op, x - 1, y);
                }
                else if (num_ways == 2 && op.pos[x - 1, y] == 1)
                {
                    p.pos[x - 1, y] = 1;
                    check(sender, p, op, x - 1, y);
                }
                else
                {
                    //p.pos[x - 1, y]--;
                    op.pos[x - 1, y] = 0;
                    //check(sender, p, op, x - 1, y);
                }
                /*

                  if (op.pos[x - 1, y] > 0)
                  {
                      p.pos[x - 1, y] = op.pos[x - 1, y] + 1;
                      op.pos[x - 1, y] = 0;
                      p.pos[x - 1, y]--;
                  }
                  else
                  {   p.pos[x - 1, y]++;

                  }

                  check(sender, p, op, x - 1, y);*/

                //
            }
            if (x + 1 <= 7)
            {
                var brush2 = new ImageBrush();

                if (op.pos[x + 1, y] > 0)
                {
                    p.pos[x + 1, y] = op.pos[x + 1, y] + 1;
                    //op.pos[x + 1, y] = 0;
                    //check(sender, p, op, x + 1, y);
                }
                else
                {
                    p.pos[x + 1, y] = 1;
                    //check(sender, p, op, x + 1, y);
                }

                //
                if (decideplayer % 2 == 0)
                {
                    if (p.pos[x + 1, y] == 1)
                    {
                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));

                    }
                    else if (p.pos[x + 1, y] == 2)
                    {

                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        //tb.Text = "\nopp  ind" + x + "  " + y + "    " + p.pos[x + 1, y] + "x+1......2 red set";
                    }

                    else if (p.pos[x + 1, y] == 3)
                    {
                        // tb.Text = "\nte....t";
                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                    }

                }
                else
                {
                    if (p.pos[x + 1, y] == 1)
                    {
                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                    }
                    else if (p.pos[x + 1, y] == 2)
                    {
                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                    }

                    else if (p.pos[x + 1, y] == 3)
                    {
                        brush2.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));
                    }

                }
                Button bn = b[x + 1, y];
                bn.Background = brush2;
                if (num_ways == 4 && op.pos[x + 1, y] == 3)
                {
                    p.pos[x + 1, y] = 3;
                    check(sender, p, op, x + 1, y);
                }
                else if (num_ways == 3 && op.pos[x + 1, y] == 2)
                {
                    p.pos[x + 1, y] = 2;
                    check(sender, p, op, x + 1, y);
                }
                else if (num_ways == 2 && op.pos[x + 1, y] == 1)
                {
                    p.pos[x + 1, y] = 1;
                    check(sender, p, op, x + 1, y);
                }
                else
                {
                    // p.pos[x + 1, y]--;
                    op.pos[x + 1, y] = 0;
                    //check(sender, p, op, x + 1, y);
                }
                /*
               if (op.pos[x +1, y] > 0)
               {
                   p.pos[x + 1, y] = op.pos[x +1, y] + 1;
                   op.pos[x +1, y] = 0;
                 //  p.pos[x + 1, y]--;
               }
               else
               {
                   p.pos[x + 1, y]++;

               }

               check(sender, p, op, x + 1, y);*/

                //
            }

            if (y - 1 >= 0)
            {
                var brush3 = new ImageBrush();

                if (op.pos[x, y - 1] > 0)
                {
                    p.pos[x, y - 1] = op.pos[x, y - 1] + 1;
                    //op.pos[x , y-1] = 0;
                    //check(sender, p, op, x , y-1);
                }
                else
                {
                    p.pos[x, y - 1] = 1;
                    // check(sender, p, op, x, y - 1);
                }

                if (decideplayer % 2 == 0)
                {
                    if (p.pos[x, y - 1] == 1)
                    {
                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));

                    }
                    else if (p.pos[x, y - 1] == 2)
                    {
                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        //tb.Text = "\nopp  ind" + x + "  " + y + "    " + p.pos[x , y-1] + "y-1.......2 red set";
                    }

                    else if (p.pos[x, y - 1] == 3)
                    {
                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                    }

                }
                else
                {

                    if (p.pos[x, y - 1] == 1)
                    {
                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                    }
                    else if (p.pos[x, y - 1] == 2)
                    {
                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                    }

                    else if (p.pos[x, y - 1] == 3)
                    {

                        brush3.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));
                    }

                }
                Button bn = b[x, y - 1];

                bn.Background = brush3;

                if (num_ways == 4 && op.pos[x, y - 1] == 3)
                {
                    p.pos[x, y - 1] = 3;
                    check(sender, p, op, x, y - 1);
                }
                else if (num_ways == 3 && op.pos[x, y - 1] == 2)
                {
                    p.pos[x, y - 1] = 2;
                    check(sender, p, op, x, y - 1);
                }
                else if (num_ways == 2 && op.pos[x, y - 1] == 1)
                {
                    p.pos[x, y - 1] = 1;
                    check(sender, p, op, x, y - 1);
                }
                else
                {
                    //p.pos[x , y-1]--;
                    op.pos[x, y - 1] = 0;
                    //check(sender, p, op, x , y-1);
                }    /*
               if (op.pos[x , y-1] > 0)
               {
                   p.pos[x, y - 1] = op.pos[x , y-1] + 1;
                   op.pos[x, y - 1] = 0;
                  // p.pos[x, y - 1]--;
               }
               else
               {
                   p.pos[x, y - 1]++;

               }

               check(sender, p, op, x , y-1);*/

            }
            if (y + 1 <= 6)
            {
                var brush4 = new ImageBrush();
                if (op.pos[x, y + 1] > 0)
                {
                    p.pos[x, y + 1] = op.pos[x, y + 1] + 1;
                    //op.pos[x, y+1] = 0;
                    //  check(sender, p, op, x, y +1);
                }
                else
                {
                    p.pos[x, y + 1] = 1;
                }

                //
                if (decideplayer % 2 == 0)
                {
                    if (p.pos[x, y + 1] == 1)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                    }
                    else if (p.pos[x, y + 1] == 2)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                    }

                    else if (p.pos[x, y + 1] == 3)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                    }

                }
                else
                {
                    if (p.pos[x, y + 1] == 1)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                    }
                    else if (p.pos[x, y + 1] == 2)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                    }

                    else if (p.pos[x, y + 1] == 3)
                    {
                        brush4.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));
                    }

                }
                Button bn = b[x, y + 1];
                bn.Background = brush4;
                if (num_ways == 4 && op.pos[x, y + 1] == 3)
                {
                    p.pos[x, y + 1] = 3;
                    check(sender, p, op, x, y + 1);
                }
                else if (num_ways == 3 && op.pos[x, y + 1] == 2)
                {
                    p.pos[x, y + 1] = 2;
                    check(sender, p, op, x, y + 1);
                }
                else if (num_ways == 2 && op.pos[x, y + 1] == 1)
                {
                    p.pos[x, y + 1] = 1;
                    check(sender, p, op, x, y + 1);
                }
                else
                {
                    //p.pos[x, y+1]--;
                    op.pos[x, y + 1] = 0;
                    //check(sender, p, op, x, y + 1);

                }
            }
            /*
               if (op.pos[x, y + 1] > 0)
               {
               p.pos[x, y + 1] = op.pos[x, y + 1] + 1;
               op.pos[x, y + 1] = 0;
              // p.pos[x, y + 1]--;
               }
               else
               {
               p.pos[x, y + 1]++;

               }

               check(sender, p, op, x, y + 1);*/
        }
Exemple #4
0
        private void check(object sender, player p, player op, int x, int y)
        {
            if ((x == 0 || x == 7) && (y == 0 || y == 6)) // corners
            {
                // tb.Text  = "  corner  " + p.pos[x, y] + "  x :  " + x + "  y  :" + y;
                if (p.pos[x, y] == 1)
                {
                    blast(sender, p, op, 2, x, y);
                    p.pos[x, y] = 0;
                    op.pos[x, y] = 0;
                    var brush = new ImageBrush();
                    brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/transparent.png"));
                    b[x, y].Background = brush;
                }
                else
                {

                    var brush5 = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        brush5.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        Button bn = (Button)sender;
                        bn.Background = brush5;
                        bn.UpdateLayout();
                    }
                    else
                    {

                        brush5.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        Button bn = (Button)sender;
                        bn.Background = brush5;
                    }
                    p.pos[x, y]++;
                }

            }

            else if ((x > 0 && x < 7) && (y > 0 && y < 6))  //middle
            {

                if (p.pos[x, y] == 3)
                {
                    blast(sender, p, op, 4, x, y);
                    p.pos[x, y] = 0;
                    op.pos[x, y] = 0;
                    var brush = new ImageBrush();
                    brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/transparent.png"));
                    b[x, y].Background = brush;
                }
                else
                {

                    var brush = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        }

                        else if (p.pos[x, y] == 2)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                        }

                        Button bn = (Button)sender;
                        bn.Background = brush; bn.Foreground = brush;
                        bn.Foreground = brush;

                    }
                    else
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                        }

                        else if (p.pos[x, y] == 2)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));
                        }
                        //brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));

                        Button bn = (Button)sender;
                        bn.Background = brush; bn.Foreground = brush;
                        bn.Foreground = brush;

                    }
                    p.pos[x, y]++;
                }
            }
            else if (((x == 0 || x == 7) && (y > 0 && y < 6)) || ((y == 0 || y == 6) && (x > 0 && x < 7)))
            {
                // tb.Text  = "  sidemid " + p.pos[x, y]+"  x :  "+x+"  y  :"+y;

                if (p.pos[x, y] == 2)
                {
                    blast(sender, p, op, 3, x, y);
                    p.pos[x, y] = 0;
                    op.pos[x, y] = 0;
                    var brush = new ImageBrush();
                    brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/transparent.png"));
                    b[x, y].Background = brush;
                }
                else
                {

                    var brush = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        }

                        Button bn = (Button)sender;
                        bn.Background = brush; bn.Foreground = brush;

                    }
                    else
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                        }

                        //brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));

                        Button bn = (Button)sender;
                        bn.Background = brush; bn.Foreground = brush;

                    }
                    p.pos[x, y]++;
                }

            }
        }
        private void check(object sender, player p, player op, int x, int y)
        {
            if (x == 0 || x == 7 && y == 0 || y == 7) // corners
            {
                if (p.pos[x, y] == 1)
                {
                    blast(sender, p, op, 2, x, y);
                }
                else
                {
                    var brush = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    else
                    {
                        brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    p.pos[x, y]++;
                }
            }

            else if ((x > 0 && x < 7) && (y > 0 && y < 6))  //middle
            {
                if (p.pos[x, y] == 3)
                {
                    blast(sender, p, op, 4, x, y);
                }
                else
                {
                    var brush = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        }

                        else if (p.pos[x, y] == 2)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballred.png"));
                        }

                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    else
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                        }

                        else if (p.pos[x, y] == 2)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/threeballyellow.png"));
                        }
                        //brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));

                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    p.pos[x, y]++;
                }
            }
            else if (((x == 0 || x == 7) && (y > 0 || y < 6)) || ((y == 0 || y == 6) && (x > 0 || x < 7)))
            {
                if (p.pos[x, y] == 2)
                {
                    blast(sender, p, op, 3, x, y);
                }
                else
                {
                    var brush = new ImageBrush();
                    if (decideplayer % 2 == 0)
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballred.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballred.png"));
                        }

                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    else
                    {
                        if (p.pos[x, y] == 0)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));
                        }
                        else if (p.pos[x, y] == 1)
                        {
                            brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/twoballyellow.png"));
                        }

                        //brush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/oneballyellow.png"));

                        Button b = (Button)sender;
                        b.Background = brush;
                    }
                    p.pos[x, y]++;
                }
            }
        }