Exemple #1
0
        private void Bepaal(int x, int y)                             //decides how moves will be made
        {
            Vakje vank     = _bord.vak[x, y];                         //saves the vakje from the current click
            Vakje oudvakje = _bord.vak[_eersteclickX, _eersteclickY]; //saves the vakje from the first click

            if (_Playerturn)                                          //if it is the playerturn then de color that is used will be red
            {
                _kleur = _mens.SpelerKleur;
            }
            else             //otherwise the color will be blue
            {
                _kleur = _computer.SpelerKleur;
            }

            if (!_eersteclick) //checks if zet is 1, if so it will call Check method in class Vakje
            {
                vank.Check(_kleur, _bord.vak[x, y].color, _tweedeclickcords, oudvakje);
            }

            if (vank.GetBepaal == false && _eersteclick)  //this will save the cordinates of the clicked vakje. This is used to see what the first clicked vakje was
            {
                _eersteclickX = x;
                _eersteclickY = y;
            }

            if (_kleur == _bord.vak[x, y].color && _eersteclick) //checks if the color of the vakje that is first clicked is the same as the color from the player
            {
                _eersteclick      = false;
                _tweedeclickcords = _bord.vak[x, y].coordinaten;
            }

            if (vank.GetBepaal)                                                                            //when set is legit, call the method VeranderKleur in class Vakje
            {
                vank.VeranderKleur(_bord._buffer, vank.coordinaten, vank.vakSize, _kleur);                 //sends information to aantalspelers

                if ((_eersteclickX + _eersteclickY) % CalculatedInt == _StartWaarde && vank.GetDubbelezet) //if the first clicked vakje is on an even number & Dubbulezet is true then make that vakje back to white
                {
                    oudvakje.ResetColor(_bord._buffer, oudvakje.coordinaten, oudvakje.vakSize, Brushes.White);
                }

                else if ((_eersteclickX + _eersteclickY) % CalculatedInt != _StartWaarde && vank.GetDubbelezet) //if the first clicked vakje is not on an even number & Dubbulezet is true then make that vakje back to black
                {
                    oudvakje.ResetColor(_bord._buffer, oudvakje.coordinaten, oudvakje.vakSize, Brushes.Black);
                }

                _Playerturn  = !_Playerturn; //reverse the playerturn bool
                _eersteclick = true;         //makes the zet int back to 0 so the next time you have to click again on the vakje you want to move
                vank.ResetBepaal();
            }
        }
Exemple #2
0
        public void Maak(PictureBox pbMain)  //bitmap is given to a vakje, vakje desides its own place an size and draws itself. After that he will return the bitmap
        {
            Vakje _vakje;                    //all the attributes from Vakje

            pbMain.Height = _buffer.Height;  //pbmain height is the same as buffer height
            pbMain.Width  = _buffer.Width;   //pbmain width is the same as buffer width

            for (int x = nul; x < size; x++) //makes the field
            {
                for (int y = nul; y < size; y++)
                {
                    _vakje = new Vakje();                       //association with vakje
                    _vakje.TekenSpel(_buffer, x, y);            //activates method Tekenspel
                    vak[x, y] = _vakje;
                }
            }
            pbMain.Image = _buffer;     //pbmain image is the buffer again
            BuurCheck(vak);             //activate BuurCheck method
        }
Exemple #3
0
 public void Check(Brush kleur, Brush vakkleur, int[] cordinaten, Vakje oudvak) //checks if the set is legal
 {
     _bepaal = false;
     if (computer.SpelerKleur != vakkleur && mens.SpelerKleur != vakkleur)
     {
         foreach (Vakje vakje in buren)                                                          //loops through every neighbour vakje of the clicked vakje
         {
             if (vakje.coordinaten[0] == cordinaten[0] && vakje.coordinaten[1] == cordinaten[1]) //is the first clicked vakje one of my nabour vakjes?
             {
                 _bepaal = true;                                                                 //if so then bepaal is set to true. Which means that the set is legal
             }
             if (_bepaal)                                                                        //if bepaal is true, stop foreach
             {
                 break;
             }
         }
         if (!_bepaal) //if bepaal is still not true then this will loop through every neighbour again to see if the first clicked vakje is next to a neighbour vakje from the last clicked vakje
         {
             foreach (Vakje vakje in buren)
             {
                 if (vakje.coordinaten[0] - vakSize == cordinaten[0] && vakje.coordinaten[1] - vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] - vakSize == cordinaten[0] && vakje.coordinaten[1] + vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] - vakSize == cordinaten[0] && vakje.coordinaten[1] == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] == cordinaten[0] && vakje.coordinaten[1] + vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] + vakSize == cordinaten[0] && vakje.coordinaten[1] + vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] + vakSize == cordinaten[0] && vakje.coordinaten[1] == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] + vakSize == cordinaten[0] && vakje.coordinaten[1] - vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 else if (vakje.coordinaten[0] == cordinaten[0] && vakje.coordinaten[1] - vakSize == cordinaten[1])
                 {
                     _bepaal     = true;
                     _dubbelezet = true;
                 }
                 if (_bepaal)
                 {
                     break;
                 }
             }
         }
     }
 }
Exemple #4
0
 public void ZetBuur(Vakje vakje)         //add the buur to the list
 {
     buren.Add(vakje);
 }