public void BlockGridConstructorTest() { BlockGrid grid = new BlockGrid(5, 6); Assert.AreEqual(5, grid.GetGridColumnCount()); Assert.AreEqual(6, grid.GetGridRowCount()); Assert.AreEqual(grid.GetGridColumnCount(), grid.grid.Length); for (int i = 0; i < grid.GetGridColumnCount(); i++) { Assert.AreEqual(grid.GetGridRowCount(), grid.grid[i].Length); } }
//--------------------------------------------------------------------- // GamePlay testing Grid environment set-up methods //--------------------------------------------------------------------- public void InitTestingBlockGrid_NonConsecutiveLinesScenario(BlockGrid grid) { if (grid.GetGridRowCount() == 30 && grid.GetGridColumnCount() == 10) { GameShape shape1 = new SquareShape(new Block(0, 1)); grid.PlaceShape(shape1); GameShape shape2 = new SquareShape(new Block(2, 1)); grid.PlaceShape(shape2); GameShape shape3 = new SquareShape(new Block(4, 1)); grid.PlaceShape(shape3); GameShape shape4 = new SquareShape(new Block(6, 1)); grid.PlaceShape(shape4); //NOTE:: Line only removed on is.Placed update (when a block is placed -- checks if lines need to be removed) GameShape shape5 = new LineShape(new Block(8, 2), ShapeRenderer.Orientation.ORIENT_1); grid.PlaceShape(shape5); // Non consecutive line GameShape shape6 = new SquareShape(new Block(6, 3)); grid.PlaceShape(shape6); GameShape shape7 = new L2Shape(new Block(2, 3)); grid.PlaceShape(shape7); GameShape shape8 = new L2Shape(new Block(5, 3)); grid.PlaceShape(shape8); } }
// Author: Samuel Stahl //Checks first for illegal move and returns true if found // else returns false if move is legal //After illegal move check, checks for imenent collision with bottom or block in grid and sets AboutToPlace if true public static bool CheckForCollisions(BlockGrid grid, List <Block> blocks, GameShape shape) { List <Vector2> occupiedCoordinates = grid.GetOccupiedCoordinates(); //Checks for illegal collisions with boundary or occupied areas and returns true if collision found foreach (Block b in blocks) { Vector2 blockCoord = b.GetPosition(); //left boundary check if (blockCoord.X < 0) { return(true); } //right boundary check else if (blockCoord.X >= grid.GetGridColumnCount()) { return(true); } //bottom boundary check else if (blockCoord.Y < 0) { return(true); } //check for illegal overlap else if (occupiedCoordinates.Contains(blockCoord)) { return(true); } } return(false); }
public void InitTestingBlockGrid_DoubleLineScenario(BlockGrid grid) { if (grid.GetGridRowCount() == 30 && grid.GetGridColumnCount() == 10) { GameShape shape1 = new SquareShape(new Block(0, 1)); grid.PlaceShape(shape1); GameShape shape2 = new SquareShape(new Block(2, 1)); grid.PlaceShape(shape2); GameShape shape3 = new SquareShape(new Block(4, 1)); grid.PlaceShape(shape3); GameShape shape4 = new SquareShape(new Block(6, 1)); grid.PlaceShape(shape4); //NOTE:: Line only removed on is.Placed update (when a block is placed -- checks if lines need to be removed) //GameShape shape5 = new SquareShape(new Block(8, 1)); //grid.PlaceShape(shape5); } }