/// <summary> /// KnockDownWall receives the row, column and direction information and /// calculates the coordinates before sending off the SquareWallRemoved /// event with LineDrawnEventArgs. /// </summary> /// <param name="row">the row of the square</param> /// <param name="col">the column of the square</param> /// <param name="dir">the direction of the wall to knock down</param> private void KnockDownWall(int row, int col, GridPoint.Direction dir) { // Compute coordinates of line segment to remove int c1 = 0, r1 = 0, c2 = 0, r2 = 0; if (dir == GridPoint.Direction.UP) { c1 = col * adjustedSquareSize + 1; c2 = (col + 1) * adjustedSquareSize - 1; r1 = r2 = row * adjustedSquareSize; } else if (dir == GridPoint.Direction.RIGHT) { r1 = row * adjustedSquareSize + 1; r2 = (row + 1) * adjustedSquareSize - 1; c1 = c2 = (col + 1) * adjustedSquareSize; } else if (dir == GridPoint.Direction.DOWN) { c1 = col * adjustedSquareSize + 1; c2 = (col + 1) * adjustedSquareSize - 1; r1 = r2 = (row + 1) * adjustedSquareSize; } else if (dir == GridPoint.Direction.LEFT) { r1 = row * adjustedSquareSize + 1; r2 = (row + 1) * adjustedSquareSize - 1; c1 = c2 = col * adjustedSquareSize; } //Notify the observer to erase the line LineDrawnEventArgs lineArgs = new LineDrawnEventArgs(); lineArgs.C1 = c1; lineArgs.C2 = c2; lineArgs.R1 = r1; lineArgs.R2 = r2; lineArgs.color = backgroundColor; SquareWallRemoved(this, lineArgs); }
/// <summary> /// KnockDownWall receives the square Id and direction information and /// calls a different version KnockDownWall with row and column information. /// </summary> /// <param name="squareId">the id of the the square</param> /// <param name="dir">the direction of the wall to knock down</param> private void KnockDownWall(int squareId, GridPoint.Direction dir) { KnockDownWall(GetRow(squareId), GetColumn(squareId), dir); }