public void ApplyActionTestMoveDownNoCollision() { Block anchor = new Block(4, 4); SquareShape shape = new SquareShape(anchor, defaultOri); List <Vector2> coordinates = new List <Vector2>(); foreach (Block b in shape.blocks) { coordinates.Add(new Vector2(b.GetX(), b.GetY())); } BlockGrid grid = new BlockGrid(10, 10); MovementManager.ApplyAction(InputAction.MoveDown, grid, shape); List <Vector2> expectedCoord = new List <Vector2>(); foreach (Block b in shape.blocks) { expectedCoord.Add(new Vector2(b.GetX(), b.GetY())); } int i = 0; while (i < coordinates.Count() && i < expectedCoord.Count()) { Assert.AreEqual(expectedCoord.ElementAt(i).X, coordinates.ElementAt(i).X); Assert.AreEqual(expectedCoord.ElementAt(i).Y, coordinates.ElementAt(i).Y - 1); i++; } Assert.IsFalse(shape.isPlaced); }
public void ApplyActionTestMoveDownCollision() { Block anchor = new Block(1, 2); SquareShape shape = new SquareShape(anchor, defaultOri); BlockGrid grid = new BlockGrid(10, 10); shape.AboutToPlaceGameShape(); MovementManager.ApplyAction(InputAction.MoveDown, grid, shape); Assert.IsTrue(shape.isPlaced); }
public void ApplyActionTestMoveRightNoCollision() { Block anchor1 = new Block(1, 1); Block anchor2 = new Block(1, 3); SquareShape shape1 = new SquareShape(anchor1, defaultOri); SquareShape shape2 = new SquareShape(anchor2, defaultOri); BlockGrid grid = new BlockGrid(10, 10); grid.PlaceShape(shape1); shape2.AboutToPlaceGameShape(); Assert.IsTrue(shape2.isAboutToPlace); MovementManager.ApplyAction(InputAction.MoveRight, grid, shape2); MovementManager.ApplyAction(InputAction.MoveRight, grid, shape2); Assert.IsFalse(shape2.isAboutToPlace); }