コード例 #1
0
ファイル: Form1.cs プロジェクト: TristanRan/JeuDame
        private void generateDamier()
        {
            panelPriseBlanc.BackColor = Color.Bisque;
            panelPriseNoir.BackColor  = Color.Bisque;

            btnGrid = new BtnCase[8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    btnGrid[j, i]        = new BtnCase();
                    btnGrid[j, i].Height = 75;
                    btnGrid[j, i].Width  = 75;
                    panel1.Controls.Add(btnGrid[j, i]);
                    btnGrid[j, i].Location = new Point(i * 75, j * 75);
                    btnGrid[j, i].position = new Point(j, i);
                    btnGrid[j, i].FlatAppearance.BorderSize = 0;
                    btnGrid[j, i].Click += Grid_Button_Click;

                    if ((i + j) % 2 == 0)
                    {
                        btnGrid[j, i].BackColor = Color.Chocolate;
                    }
                    else
                    {
                        btnGrid[j, i].BackColor = Color.Beige;
                        btnGrid[j, i].Enabled   = false;
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: TristanRan/JeuDame
        private void Grid_Button_Click(object sender, EventArgs e)
        {
            BtnCase btnCase = sender as BtnCase;

            if (damier.selectedPiece == null)
            {
                ReinitializeBtnBorder();


                Point selectPiece = new Point(btnCase.position.X, btnCase.position.Y);


                if (damier.tab2D.PieceExistInPosition(selectPiece))
                {
                    damier.selectPion(selectPiece);

                    SelectionnedPiece(btnGrid[damier.selectedPiece.position.X, damier.selectedPiece.position.Y]);
                    blockPieces();

                    foreach (Point point in damier.authorizedMouvement)
                    {
                        BtnCase selected = btnGrid[point.X, point.Y];
                        PossibleMouvementInRed(selected);
                        selected.Enabled = true;
                    }

                    foreach (PathRemove remove in damier.positionSauterAutorise)
                    {
                        BtnCase selected = btnGrid[remove.CoordonneAfterManger.X, remove.CoordonneAfterManger.Y];
                        PossibleMouvementInRed(selected);
                        selected.Enabled = true;
                    }
                }
            }
            else
            {
                damier.aSaute = false;

                damier.movePion(btnCase.position);

                refreshDamier();
                ReinitializeBtnBorder();

                if (damier.aSaute && damier.positionSauterAutorise.Count != 0)
                {
                    SelectionnedPiece(btnGrid[damier.selectedPiece.position.X, damier.selectedPiece.position.Y]);
                    blockPieces();
                    foreach (PathRemove remove in damier.positionSauterAutorise)
                    {
                        BtnCase selected = btnGrid[remove.CoordonneAfterManger.X, remove.CoordonneAfterManger.Y];
                        PossibleMouvementInRed(selected);
                        selected.Enabled = true;
                    }
                }
                else
                {
                    ReinitializeBtnBorder();
                    damier.selectedPiece = null;
                    blockPieces();
                    OnMouvementDone(e);
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: TristanRan/JeuDame
 private void SelectionnedPiece(BtnCase btn)
 {
     btn.FlatAppearance.BorderSize = 5;
     btn.FlatStyle = FlatStyle.Flat;
     btn.FlatAppearance.BorderColor = Color.Blue;
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: TristanRan/JeuDame
 private void PossibleMouvementInRed(BtnCase btn)
 {
     btn.FlatAppearance.BorderSize = 5;
     btn.FlatStyle = FlatStyle.Flat;
     btn.FlatAppearance.BorderColor = Color.Red;
 }