Exemple #1
0
 public static Piece construct(string nom, int horizontal, int vertical, bool color)
 {
     Piece obj;
     switch (nom)
     {
         case "Pion":
             obj = new Pion(horizontal, vertical, color);
             break;
         case "Tour":
             obj = new Tour(horizontal, vertical, color);
             break;
         case "Fou":
             obj = new Fou(horizontal, vertical, color);
             break;
         case "Cavalier":
             obj = new Cavalier(horizontal, vertical, color);
             break;
         case "Roi":
             obj = new Roi(horizontal, vertical, color);
             break;
         case "Dame":
             obj = new Dame(horizontal, vertical, color);
             break;
         default:
             obj = null;
             break;
     }
     return obj;
 }
Exemple #2
0
        private void SetWhiteChessMan()
        {
            foreach (Case kz in m_board.m_cases)
            {
                if (kz.m_center.Y <= 660)
                {
                    continue;
                }
                if (kz.m_center.Y == 900)
                {
                    break;
                }
                Pion pion = new Pion();
                pion.SetWindow(ref m_window);
                pion.SetTexture(ref m_whiteChess);
                pion.GetSprite.Position = kz.m_center;
                pion.Position           = kz.m_center;
                pion.Color      = Color.White;
                pion.Boundaries = new FloatRect(pion.Position.X - (kz.m_boundaries.Width / 2.0f), pion.Position.Y - (kz.m_boundaries.Height / 2.0f), kz.m_boundaries.Width, kz.m_boundaries.Height);
                pion.SetBoard(ref m_board);
                m_joueur1.Add(pion);
            }

            Tour tour1 = new Tour();

            tour1.SetWindow(ref m_window);
            tour1.SetTexture(ref m_whiteChess);
            tour1.GetSprite.Position = new Vector2f(60, 900);
            tour1.Position           = new Vector2f(60, 900);
            tour1.Color      = Color.White;
            tour1.Boundaries = new FloatRect(tour1.Position.X - (m_board.m_cases[0].m_boundaries.Width / 2.0f), tour1.Position.Y - (m_board.m_cases[0].m_boundaries.Height / 2.0f), m_board.m_cases[0].m_boundaries.Width, m_board.m_cases[0].m_boundaries.Height);
            tour1.SetBoard(ref m_board);
            m_joueur1.Add(tour1);

            Tour tour2 = new Tour();

            tour2.SetWindow(ref m_window);
            tour2.SetTexture(ref m_whiteChess);
            tour2.GetSprite.Position = new Vector2f(900, 900);
            tour2.Position           = new Vector2f(900, 900);
            tour2.Color      = Color.White;
            tour2.Boundaries = new FloatRect(tour2.Position.X - (m_board.m_cases[0].m_boundaries.Width / 2.0f), tour2.Position.Y - (m_board.m_cases[0].m_boundaries.Height / 2.0f), m_board.m_cases[0].m_boundaries.Width, m_board.m_cases[0].m_boundaries.Height);
            tour2.SetBoard(ref m_board);
            m_joueur1.Add(tour2);
        }
Exemple #3
0
 private void SetBlackChessMan()
 {
     foreach (Case kz in m_board.m_cases)
     {
         if (kz.m_center.Y == 60)
         {
             continue;
         }
         if (kz.m_center.Y > 180)
         {
             break;
         }
         Pion pion = new Pion();
         pion.SetWindow(ref m_window);
         pion.SetTexture(ref m_blackChess);
         pion.GetSprite.Position = kz.m_center;
         pion.Position           = kz.m_center;
         pion.Color      = Color.Black;
         pion.Boundaries = new FloatRect(pion.Position.X - (kz.m_boundaries.Width / 2.0f), pion.Position.Y - (kz.m_boundaries.Height / 2.0f), kz.m_boundaries.Width, kz.m_boundaries.Height);
         pion.SetBoard(ref m_board);
         m_joueur2.Add(pion);
     }
 }
Exemple #4
0
 public static void initPion(int ligne, bool color)
 {
     int j = 0;
     for (j = 0; j < 8; j++)
     {
         plateau[ligne, j] = new Pion(ligne, j, color);
     }
 }
Exemple #5
0
        public static void tour(bool joueur)
        {
            int horizontal;
            int vertical;
            int newHorizontal;
            int newVertical;
            Piece select = new Pion(9, 9, true);
            if(joueur)
            {
                Console.WriteLine("Joueur blanc c'est à vous.");
            }
            else
            {
                Console.WriteLine("Joueur noir c'est à vous.");
            }
            do
            {
                Console.Write("Entrer la valeur horizontale de votre piece: ");
                horizontal = readHorizon();
                Console.Write("Entrer la valeur verticale de votre piece: ");
                vertical = readVertical();
                if (plateau[horizontal, vertical] is Piece)
                    select = (Piece)plateau[horizontal, vertical];
                else
                    continue;
            } while (select.getColor()!=joueur);
            select = (Piece)plateau[horizontal, vertical];
            select.atteinte();
            list = select.getList();
            Console.Clear();
            affiche();
            
            do
            {
                Console.Write("Entrer la valeur horizontale de la case cible: ");
                newHorizontal = readHorizon();
                Console.Write("Entrer la valeur verticale de la case cible: ");
                newVertical = readVertical();
            } while (!(list.Any(test => test.Equals(plateau[newHorizontal, newVertical]))));

            if (!(plateau[newHorizontal, newVertical] is Piece))
            {
                echange((Piece)plateau[horizontal, vertical], plateau[newHorizontal, newVertical]);
                if (plateau[newHorizontal, newVertical] is Roi)
                {
                    mouvRoi((Piece)plateau[newHorizontal, newVertical], joueur);
                }
            }
            else
            {
                echange((Piece)plateau[horizontal, vertical], (Piece)plateau[newHorizontal, newVertical]);
                if(plateau[newHorizontal,newVertical] is Roi)
                {
                    mouvRoi((Piece)plateau[newHorizontal, newVertical], joueur);
                }
            }
            select = (Piece)plateau[newHorizontal, newVertical];
            select.atteinte();
            list = select.getList();
            list = null;
        }