예제 #1
0
        public void Start(Color BorderColor)
        {
            //Hij maakt een nieuw schaakbord waarin de logica zit
            Schaakbord schaakbord = new Schaakbord(Variant, this, Speler1, Speler2, ColorVakje1, ColorVakje2);

            this.schaakbord = schaakbord;

            //Hij maakt een nieuw speelbord (een window)
            SpeelBord speelbord = new SpeelBord(this, schaakbord, Variant, BorderColor);

            this.speelbord = speelbord;
            speelbord.Show();
        }
예제 #2
0
        }                                                  //int die bijhoud welk menu van regels je zit

        public SpeelBord(Spel spel, Schaakbord schaakbord, string Variant, Color borderColor)
        {
            _spel         = spel;
            _clicks       = 0;
            this._variant = Variant;
            InitializeComponent();
            if (_spel.Speler1.Naam == "")
            {
                _spel.Speler1.Naam = "Wit";
            }
            if (_spel.Speler2 != null && _spel.Speler2.Naam == "")
            {
                _spel.Speler2.Naam = "Zwart";
            }

            lblbeurt.Text = _spel.Speler1.Naam + " is aan zet";
            this.CenterToScreen();
            lblaantal2.Text = Convert.ToString(_spel.Speler1.ResterendeStukken); //hier moet de variabele komen voor het aantal van wit
            if (spel.SpelMode != "Singleplayer")
            {
                lblaantal1.Text = Convert.ToString(_spel.Speler2.ResterendeStukken); //hier moet de variabele komen voor het aantal van wit
            }
            else
            {
                lblaantal1.Text = Convert.ToString(_spel.ComputerSpeler.ResterendeStukken); //hier moet de variabele komen voor het aantal van wit
            }
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    // Maak pictureboxes
                    SpecialPB pictureBox = new SpecialPB();
                    pictureBox.Location = new Point(12 + 54 * y, 50 + 54 * x);
                    pictureBox.Size     = new Size(54, 54);
                    pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
                    pictureBox.TabIndex = 0;
                    pictureBox.TabStop  = false;
                    this.Controls.Add(pictureBox);

                    // Koppel SpecialPB aan Vakje
                    pictureBox.vakje     = schaakbord.SchaakArray[x, y];
                    pictureBox.BackColor = pictureBox.vakje.Kleur;
                    schaakbord.SchaakArray[x, y].Pbox = pictureBox;

                    pictureBox.update(); // Laat schaakstukken zien

                    pictureBox.Click += new EventHandler((o, a) => select(pictureBox));
                }
            }
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.pictureBox1.BackgroundImage       = Properties.Resources.border_transparent;
            pictureBox1.BackColor                  = borderColor;
            this.pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
            this.pictureBox1.Location              = new System.Drawing.Point(1, 36);
            this.pictureBox1.Name                  = "pictureBox1";
            this.pictureBox1.Size                  = new System.Drawing.Size(460, 460);
            this.pictureBox1.TabIndex              = 20;
            this.pictureBox1.TabStop               = false;
            this.Controls.Add(pictureBox1);

            // Het spel is singleplayer of multiplayer
            if (_spel.SpelMode.Equals("Singleplayer"))
            {
                lblPlayer1.Text = _spel.Speler1.Naam;
                lblPlayer2.Text = "COMP";
            }
            else if (_spel.SpelMode.Equals("Multiplayer"))
            {
                lblPlayer1.Text = "P1: " + _spel.Speler1.Naam;
                lblPlayer2.Text = "P2: " + _spel.Speler2.Naam;
            }
            else if (_spel.SpelMode.Equals("Online"))
            {
                lblPlayer1.Text = "P1: " + _spel.Speler1.Naam;
            }
        }