Exemplo n.º 1
0
 public void MoveRightTest()
 {
     //Assert
     Axis xAxis = new Axis("x");
     Direction positiveDirection = new Direction(DirectionType.Positive);
     Mover2D mover2D = new Mover2D();
     Shape shape = CreateTestShape();
     //Act
     mover2D.Move(shape, xAxis, positiveDirection);
     //Arrange
     Assert.IsTrue(shape.Points[0].Equals(new Point2D(new List<Coordinate>()
     {
         new Coordinate(6), new Coordinate(5)
     })));
     Assert.IsTrue(shape.Points[1].Equals(new Point2D(new List<Coordinate>()
     {
         new Coordinate(6), new Coordinate(6)
     })));
     Assert.IsTrue(shape.Points[2].Equals(new Point2D(new List<Coordinate>()
     {
         new Coordinate(7), new Coordinate(6)
     })));
     Assert.IsTrue(shape.Points[3].Equals(new Point2D(new List<Coordinate>()
     {
         new Coordinate(7), new Coordinate(7)
     })));
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Point2D zPoint = new Point2D(new List<Coordinate>(){
                new Coordinate(5), new Coordinate(5)
            });
            ZShape z = new ZShape(zPoint);
            var axes = AxisParser.Parse("axes.xml");
            z.Rotate(axes[0]);
            z.Rotate(axes[1]);
            Mover2D mover2D = new Mover2D();
            Direction negativeDirection = new Direction(DirectionType.Negative);
            foreach (Point2D item in z.Points)
            {
                Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")");
            }
            mover2D.Move(z, axes[0], negativeDirection);
            Console.WriteLine("-----------------");
            foreach (Point2D item in z.Points)
            {
                Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")");
            }

            Console.WriteLine("------------------------");
            ShapeFactory factory = new ShapeFactory();
            var newShape = factory.CreateShape(new Point2D(new List<Coordinate>()
            {
                new Coordinate(10), new Coordinate(8)
            }));
            foreach (Point2D item in newShape.Points)
            {
                Console.WriteLine("(" + item.X.Value + ", " + item.Y.Value + ")");
            }
        }
Exemplo n.º 3
0
 private void XMovement(Shape shape, Direction direction)
 {
     switch (direction.GetDirectionType)
     {
         case DirectionType.Negative:
             MoveLeft(shape);
             break;
         case DirectionType.Positive:
             MoveRight(shape);
             break;
     }
 }
Exemplo n.º 4
0
 public void Move(Shape shape, Axis axis, Direction direction)
 {
     switch (axis.Name)
     {
         case "x":
             XMovement(shape, direction);
             break;
         case "y":
             YMovement(shape, direction);
             break;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// probably we don't need direction here, because in common 2D tetris
 /// we can't move our shape in up direction, but
 /// we will support oportunity to move our shape in up direction
 /// it's more expected in this case and why not?
 /// </summary>
 private void YMovement(Shape shape, Direction direction)
 {
     // we will think that positive direction on Y axis is the direction
     // in which our shape moves as default
     // so positive direction matches to mothed MoveDown
     switch (direction.GetDirectionType)
     {
         case DirectionType.Negative:
             MoveUp(shape);
             break;
         case DirectionType.Positive:
             MoveDown(shape);
             break;
     }
 }