Exemple #1
0
        private bool CanMoveKnight(FigureModel figure, Vector to)
        {
            var x = Math.Abs(figure.Position.X - to.X);
            var y = Math.Abs(figure.Position.Y - to.Y);

            if (x == 2 && y == 1 || x == 1 && y == 2)
            {
                return(true);
            }
            return(false);
        }
Exemple #2
0
 //Fixed
 private bool CanMoveQueen(FigureModel figure, Vector to)
 {
     if (Math.Abs(figure.Position.X - to.X) == Math.Abs(figure.Position.Y - to.Y))
     {
         return(CanMoveBishop(figure, to));
     }
     else
     {
         return(CanMoveRook(figure, to));
     }
 }
Exemple #3
0
 //Fixed
 private bool CanMoveBishop(FigureModel figure, Vector to)
 {
     for (byte i = 1; i <= Math.Abs(figure.Position.X - to.X); i++)
     {
         if ((figure.Position.X + i == to.X && figure.Position.Y + i == to.Y) ||
             (figure.Position.X - i == to.X && figure.Position.Y - i == to.Y) ||
             (figure.Position.X + i == to.X && figure.Position.Y - i == to.Y) ||
             (figure.Position.X - i == to.X && figure.Position.Y + i == to.Y))
         {
             return(true);
         }
     }
     return(false);
 }
 public SquareModel(FigureModel figure)
 {
     this.Position = figure.Position;
     this.Figure   = figure;
 }