Exemple #1
0
    /// <summary>
    /// Used to check if there is free space for the next moove using existing shaped from shapeManager
    ///
    /// At this point we check only for for different positions, not rotations
    /// </summary>
    /// <param name="shapeManager"></param>
    /// <returns>returns false if there is no place for existing shapes</returns>
    public bool MoreMoovesPossible(IShapeManager shapeManager)
    {
        // For each shape
        for (int i = 0; i < shapeManager.shapeArray.Length; i++)
        {
            if (!shapeManager.shapeToBeDestroyed[i])
            {
                Shape shape = (Shape)shapeManager.shapeArray[i];
                // For each position
                for (int x = 0; x < matrix.Length; x++)
                {
                    for (int y = 0; y < matrix[0].Length; y++)
                    {
                        MatrixManager matrixManagerCopy = new MatrixManager(matrix.Length, matrix[0].Length);
                        matrixManagerCopy.matrix = Helper.GetArr(matrix.Length, matrix[0].Length);
                        for (int mX = 0; mX < matrix.Length; mX++)
                        {
                            for (int mY = 0; mY < matrix[0].Length; mY++)
                            {
                                matrixManagerCopy.matrix[mX][mY] = matrix[mX][mY];
                            }
                        }

                        if (matrixManagerCopy.AddShape(shape, x, y))
                        {
                            return(true);
                        }
                    }
                }
            }
        }

        return(false);
    }