Beispiel #1
0
        // ******************** MOUVEMENT POSSIBLE **********************

        /*
         * private void Buttons_MouseEnter(object sender, EventArgs e)
         * {
         *  if (sender is monBouton)
         *  {
         *      monBouton b = sender as monBouton; // cast necessaire
         *      for (int i = 0; i < piece.GetDepi().GetLength(0); ++i)
         *      {
         *          DD.GetMonBouton(b.getNumLigne() + piece.GetDepi()[i], b.getNumCol() + piece.GetDepi()[i]).Text = "X";
         *      }
         *  }
         *
         * }
         *
         * private void Buttons_MouseLeave(object sender, EventArgs e)
         * {
         *  if (sender is Button)
         *  {
         *      monBouton b = sender as monBouton;
         *      for (int i = 0; i < piece.GetDepi().GetLength(0); ++i)
         *      {
         *          DD.GetMonBouton(b.getNumLigne() + piece.GetDepi()[i], b.getNumCol() + piece.GetDepi()[i]).Text = "";
         *      }
         *  }
         * }
         */

        // ******************** AFFICHER CIBLE POSSIBLE **********************
        private void CibleAj(monBouton b, Cavalier p)
        {
            for (int i = 0; i < p.GetDepi().GetLength(0); ++i)
            {
                DD.SetButtonCible(b, piece.GetDepi()[i], piece.GetDepj()[i]);
            }
        }
Beispiel #2
0
 private bool IsRestCibleDispo(monBouton bori, Cavalier p)
 {
     for (int i = 0; i < p.GetDepi().GetLength(0); ++i)
     {
         if (DD.IsDispoCible(bori, p.GetDepi()[i], p.GetDepj()[i]))
         {
             return(true);
         }
     }
     return(false);
 }
        //  Parcours de la piece (cavalier) sur l'échiquier à partir d une case donnee
        private void IAchoixRemplissage(monBouton b)
        {
            //initialisation
            InitialisationIAChoix();
            InitialisationDamierNum();

            //simulation
            int ii = b.getNumLigne() - 1;
            int jj = b.getNumCol() - 1;

            piece = new Cavalier(b, choixCav);
            int[]  depi  = piece.GetDepi();
            int [] depj  = piece.GetDepj();
            Euler  euler = new Euler(depi, depj);

            damierNum = euler.getEchec(ii, jj);

            int       rangBouton;
            monBouton btmp;

            for (int i = 0; i < damierNum.GetLength(0); ++i)
            {
                for (int j = 0; j < damierNum.GetLength(1); ++j)
                {
                    // on ne veut pas certaines des 12*12 cases ( 0 et -1)
                    if (damierNum[i, j] >= 1)
                    {
                        //extraction
                        rangBouton = damierNum[i, j]; //rang allant de 1 à 64
                        btmp       = DD.GetMonBouton(i, j);
                        //assignation
                        IAchoix[rangBouton - 1]        = btmp; //(rang-1) allant de 0 à 63
                        IAchoixLigne[rangBouton - 1]   = btmp.getNumLigne();
                        IAchoixColonne[rangBouton - 1] = btmp.getNumCol();
                    }
                }
            }
        }