예제 #1
0
        /// <summary>
        /// Determines if a falling progression of a block will result in overlap with other blocks within the grid.
        /// </summary>
        /// <param name="block">The block to be checked.</param>
        /// <param name="grid">The grid that the block is being filled to.</param>
        /// <returns>Returns true if the current block will overlap another block in the grid if it falls one row.</returns>
        public static bool blockCollision(BlockType block, GridType grid)
        {
            bool returnValue = false;

            Vector2 newVector = block.Brick1.Vector;

            newVector.Y++;

            if (newVector.Y < 19)
            {
                if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                {
                    returnValue = true;
                }
            }

            newVector = block.Brick2.Vector;

            newVector.Y++;

            if (newVector.Y < 19)
            {
                if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                {
                    returnValue = true;
                }
            }

            newVector = block.Brick3.Vector;

            newVector.Y++;

            if (newVector.Y < 19)
            {
                if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                {
                    returnValue = true;
                }
            }

            newVector = block.Brick4.Vector;

            newVector.Y++;

            if (newVector.Y < 19)
            {
                if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                {
                    returnValue = true;
                }
            }

            return(returnValue);
        }
예제 #2
0
        /// <summary>
        /// Determines if a progression of the rotation state of a block will result in an overlap with another
        /// block in the grid.
        /// </summary>
        /// <param name="block">The block to be checked.</param>
        /// <param name="grid">The grid that the block is being filled to.</param>
        /// <returns>Returns true if a rotation by the current block will result in an overlap with another
        /// block in the game grid.</returns>
        public static bool rotationCollision(BlockType block, GridType grid)
        {
            bool returnValue = false;

            RotationData nextRotation;

            nextRotation = block.getRotation(block.Rotation);

            Vector2 newVector = block.Brick1.Vector + nextRotation.brick1Location;

            if ((newVector.X < 0 || newVector.X > 9) || (newVector.Y < 0 || newVector.Y > 18))
            {
                returnValue = true;
            }
            else if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
            {
                returnValue = true;
            }

            newVector = block.Brick2.Vector + nextRotation.brick2Location;

            if ((newVector.X < 0 || newVector.X > 9) || (newVector.Y < 0 || newVector.Y > 18))
            {
                returnValue = true;
            }
            else if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
            {
                returnValue = true;
            }

            newVector = block.Brick3.Vector + nextRotation.brick3Location;

            if ((newVector.X < 0 || newVector.X > 9) || (newVector.Y < 0 || newVector.Y > 18))
            {
                returnValue = true;
            }
            else if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
            {
                returnValue = true;
            }

            newVector = block.Brick4.Vector + nextRotation.brick4Location;

            if ((newVector.X < 0 || newVector.X > 9) || (newVector.Y < 0 || newVector.Y > 18))
            {
                returnValue = true;
            }
            else if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
            {
                returnValue = true;
            }

            return(returnValue);
        }
예제 #3
0
        /// <summary>
        /// Determines if there are blocks within the area that another block is supposed to spawn at.
        /// </summary>
        /// <param name="spawnData"></param>
        /// <param name="grid"></param>
        /// <returns></returns>
        public static bool overlapCollision(SpawnData spawnData, GridType grid)
        {
            bool returnValue = false;

            if (grid.getCell(spawnData.brick1Vector).IsFull)
            {
                returnValue = true;
            }
            else if (grid.getCell(spawnData.brick2Vector).IsFull)
            {
                returnValue = true;
            }
            else if (grid.getCell(spawnData.brick3Vector).IsFull)
            {
                returnValue = true;
            }
            else if (grid.getCell(spawnData.brick4Vector).IsFull)
            {
                returnValue = true;
            }

            return(returnValue);
        }
예제 #4
0
        /// <summary>
        /// Determines if a block will overlap another block within the grid if it
        /// moves one space in any horizontal direction.
        /// </summary>
        /// <param name="block">The block to be checked.</param>
        /// <param name="grid">The grid that the block is being filled to.</param>
        /// <param name="direction">The direction to check for overlapping blocks.</param>
        /// <returns>Returns true if a progression of one space to the specified direction of the current block
        /// results in an overlap with another block in the grid.</returns>
        public static bool blockCollision(BlockType block, GridType grid, Direction direction)
        {
            bool returnValue = false;

            Vector2 newVector;

            if (direction == Direction.left)
            {
                newVector = block.Brick1.Vector;
                newVector.X--;

                if (newVector.X > -1)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick2.Vector;
                newVector.X--;

                if (newVector.X > -1)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick3.Vector;
                newVector.X--;

                if (newVector.X > -1)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick4.Vector;
                newVector.X--;

                if (newVector.X > -1)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }
            }
            else
            {
                newVector = block.Brick1.Vector;
                newVector.X++;

                if (newVector.X < 10)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick2.Vector;
                newVector.X++;

                if (newVector.X < 10)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick3.Vector;
                newVector.X++;

                if (newVector.X < 10)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }

                newVector = block.Brick4.Vector;
                newVector.X++;

                if (newVector.X < 10)
                {
                    if (grid.getCell(newVector).IsFull&& !brickCollision(block, newVector))
                    {
                        returnValue = true;
                    }
                }
                else
                {
                    returnValue = true;
                }
            }

            return(returnValue);
        }
예제 #5
0
 public void clearGrid(GridType grid)
 {
     grid.getCell(vector).emptyCell();
 }
예제 #6
0
 public void fillGrid(GridType grid)
 {
     grid.getCell(vector).fillCell(texture, color);
 }