コード例 #1
0
 /// <summary>
 /// Constructeur de sérialisation
 /// </summary>
 /// <param name="info"></param>
 /// <param name="ctxt"></param>
 public Player(SerializationInfo info, StreamingContext ctxt)
 {
     name       = (string)info.GetValue("Name", typeof(string));
     color      = (Colors)info.GetValue("Color", typeof(Colors));
     timeLeft   = (TimeSpan)info.GetValue("TimeLeft", typeof(TimeSpan));
     timeMoving = (bool)info.GetValue("timeMoving", typeof(bool));
 }
コード例 #2
0
        /// <summary>
        /// Cherche dans la direction spécifiée un pion de la couleur
        ///  spécifié et tourne les pions croisés dans cette directions
        /// </summary>
        /// <param name="color">couleur à chercher</param>
        /// <param name="column">col</param>
        /// <param name="line">row</param>
        /// <param name="deltaX">directionX</param>
        /// <param name="deltaY">directionY</param>
        /// <param name="pawnsCrossed">liste des pions croisés (sortie)</param>
        /// <returns>True si pion même couleur trouvé, Fase Sinon</returns>
        private bool SearchInDirection(Pawn.Colors color, int column, int line, int deltaX, int deltaY, ICollection <Pawn> pawnsCrossed = null)
        {
            var hit        = false;
            var stop       = false;
            var atLeastOne = false;

            while (!stop)
            {
                line   += deltaY;
                column += deltaX;

                if (line >= HEIGHT || line < 0 || column >= WIDTH || column < 0)
                {
                    hit  = false;
                    stop = true;
                }
                else
                {
                    var currentPawn = Board[column, line];

                    if (currentPawn == null)
                    {
                        hit  = false;
                        stop = true;
                    }

                    else if (currentPawn.Color == color)
                    {
                        hit  = atLeastOne;
                        stop = true;
                    }
                    else
                    {
                        atLeastOne = true;
                    }


                    if (!stop)
                    {
                        pawnsCrossed?.Add(currentPawn);
                    }
                }
            }

            return(hit);
        }
コード例 #3
0
 /// <summary>
 /// Constructeur avec paramètres
 /// </summary>
 /// <param name="n"></param>
 /// <param name="c"></param>
 public Player(string n, Colors c)
 {
     timeLeft = maxTime;
     name     = n;
     color    = c;
 }
コード例 #4
0
 /// <summary>
 /// Ajoute un pion à la coord spécifié
 /// </summary>
 /// <param name="x">col</param>
 /// <param name="y">row</param>
 /// <param name="color">couleur</param>
 ///
 public void addPawn(int col, int line, Pawn.Colors color)
 {
     Board[col, line] = new Pawn(color, col, line);
 }
コード例 #5
0
 /// <summary>
 /// Ajoute un pion à la coord spécifié
 /// </summary>
 /// <param name="x">col</param>
 /// <param name="y">row</param>
 /// <param name="color">couleur</param>
 public void addPawn(int x, int y, Pawn.Colors color)
 {
     Board[y, x] = new Pawn(color, x, y);
 }