public void ApplyInvalidActionTest() { List <Vector2> coordinates; GameShape shape = BasicShapeInitialize(out coordinates, defaultOri); shape.ApplyAction(InputAction.Pause); }
public void Rotate0To90Test() { List <Vector2> coordinates; GameShape square = BasicShapeInitialize(out coordinates, defaultOri); //Rotate GameShape square.ApplyAction(InputAction.Rotate); //Automated way of checking if properly rotated --- NOTE:: ASSUMES rotationOffset Lists are accurate //IReadOnlyCollection<Vector2> rotationOffsets = square.GetOrientationOffsets(square.GetOrientation()); //for (int i = 0; i < coordinates.Count; i++) //{ // //Get position of // Vector2 pos = new Vector2(square.blocks.ElementAt(i).GetX(), square.blocks.ElementAt(i).GetY()); // pos -= rotationOffsets.ElementAt(i); // Assert.AreEqual(coordinates.ElementAt(i), pos); //} Assert.AreEqual(coordinates.ElementAt(0).X + 1, square.blocks.ElementAt(0).GetX()); Assert.AreEqual(coordinates.ElementAt(0).Y, square.blocks.ElementAt(0).GetY()); Assert.AreEqual(coordinates.ElementAt(1).X, square.blocks.ElementAt(1).GetX()); Assert.AreEqual(coordinates.ElementAt(1).Y - 1, square.blocks.ElementAt(1).GetY()); Assert.AreEqual(coordinates.ElementAt(2).X - 1, square.blocks.ElementAt(2).GetX()); Assert.AreEqual(coordinates.ElementAt(2).Y, square.blocks.ElementAt(2).GetY()); Assert.AreEqual(coordinates.ElementAt(3).X, square.blocks.ElementAt(3).GetX()); Assert.AreEqual(coordinates.ElementAt(3).Y + 1, square.blocks.ElementAt(3).GetY()); }
public void ApplyMoveActionTest() { List <Vector2> coordinates; GameShape shape = BasicShapeInitialize(out coordinates, defaultOri); shape.ApplyAction(InputAction.MoveDown); //ensure move function called foreach (Block b in shape.blocks) { Assert.IsTrue(coordinates.Contains(new Vector2(b.GetX(), b.GetY() + 1))); } }
private static void checkAndApply(InputAction action, BlockGrid grid, GameShape shape) { List <Block> shapeBlocks = shape.CalcBlocksPostAction(action); List <Vector2> occupiedCoordinates = grid.GetOccupiedCoordinates(); bool collision = CheckForCollisions(grid, shapeBlocks, shape); CheckForCollisions(grid, shape.blocks, shape); if (!collision) { shape.ApplyAction(action); } checkAboutToPlace(shape.blocks, shape, occupiedCoordinates); }
public void MoveRightTest() { List <Vector2> coordinates; GameShape shape = BasicShapeInitialize(out coordinates, defaultOri); shape.ApplyAction(InputAction.MoveRight); for (int i = 0; i < coordinates.Count(); i++) { // Check that X increased by 1, Y did not change Assert.AreEqual(coordinates.ElementAt(i).Y, shape.blocks.ElementAt(i).GetY()); Assert.AreEqual(coordinates.ElementAt(i).X + 1, shape.blocks.ElementAt(i).GetX()); } }
public void MoveDownTest() { List <Vector2> coordinates; GameShape shape = BasicShapeInitialize(out coordinates, defaultOri); shape.ApplyAction(InputAction.MoveDown); for (int i = 0; i < coordinates.Count(); i++) { // Check that X did not change, and Y was reduced by 1 Assert.AreEqual(coordinates.ElementAt(i).X, shape.blocks.ElementAt(i).GetX()); Assert.AreEqual(coordinates.ElementAt(i).Y - 1, shape.blocks.ElementAt(i).GetY()); } }
public void ApplyRotateActionTest() { List <Vector2> coordinates; GameShape shape = BasicShapeInitialize(out coordinates, defaultOri); shape.ApplyAction(InputAction.Rotate); //ensure rotation function called foreach (Block b in shape.blocks) { Assert.IsTrue(coordinates.Contains(b.GetPosition())); } //ensure orientation adjusted Assert.AreEqual(ShapeRenderer.Orientation.ORIENT_1, shape.GetOrientation()); }
public void Rotate180To270Test() { List <Vector2> coordinates; GameShape L2 = BasicShapeInitialize(out coordinates, ShapeRenderer.Orientation.ORIENT_2); //Rotate GameShape L2.ApplyAction(InputAction.Rotate); Assert.AreEqual(coordinates.ElementAt(0).X, L2.blocks.ElementAt(0).GetX()); Assert.AreEqual(coordinates.ElementAt(0).Y, L2.blocks.ElementAt(0).GetY()); Assert.AreEqual(coordinates.ElementAt(1).X + 1, L2.blocks.ElementAt(1).GetX()); Assert.AreEqual(coordinates.ElementAt(1).Y - 1, L2.blocks.ElementAt(1).GetY()); Assert.AreEqual(coordinates.ElementAt(2).X - 1, L2.blocks.ElementAt(2).GetX()); Assert.AreEqual(coordinates.ElementAt(2).Y - 1, L2.blocks.ElementAt(2).GetY()); Assert.AreEqual(coordinates.ElementAt(3).X - 2, L2.blocks.ElementAt(3).GetX()); Assert.AreEqual(coordinates.ElementAt(3).Y - 2, L2.blocks.ElementAt(3).GetY()); }
public void Rotate0To90Test() { List <Vector2> coordinates; GameShape L2 = BasicShapeInitialize(out coordinates, defaultOri); //Rotate GameShape L2.ApplyAction(InputAction.Rotate); Assert.AreEqual(coordinates.ElementAt(0).X, L2.blocks.ElementAt(0).GetX()); Assert.AreEqual(coordinates.ElementAt(0).Y, L2.blocks.ElementAt(0).GetY()); Assert.AreEqual(coordinates.ElementAt(1).X - 1, L2.blocks.ElementAt(1).GetX()); Assert.AreEqual(coordinates.ElementAt(1).Y + 1, L2.blocks.ElementAt(1).GetY()); Assert.AreEqual(coordinates.ElementAt(2).X + 1, L2.blocks.ElementAt(2).GetX()); Assert.AreEqual(coordinates.ElementAt(2).Y + 1, L2.blocks.ElementAt(2).GetY()); Assert.AreEqual(coordinates.ElementAt(3).X + 2, L2.blocks.ElementAt(3).GetX()); Assert.AreEqual(coordinates.ElementAt(3).Y + 2, L2.blocks.ElementAt(3).GetY()); }