/// <summary> /// Gets the link piece from the specified direction. /// </summary> /// <returns> /// The link piece. /// </returns> /// <param name='linkType'> /// Link type. /// </param> /// <param name='applyFilter'> /// Apply filter indicates if <see cref="CanBeLink"/> will be checked before returning the link. /// If "applyFilter" is true and the link board piece "CanBeLink" property returns false then "null" will be returned. /// </param> protected Match3BoardPiece GetLinkPiece(LinkType linkType, bool applyFilter = false) { Match3BoardPiece link = null; BoardCoord curPos = BoardPosition; curPos.OffsetBy(Match3BoardPiece.linkOffsets[(int)linkType]); if (curPos.row >= Board.NumRows || curPos.col >= Board.NumColumns || curPos.row < 0 || curPos.col < 0) { return(null); } link = Board[curPos] as Match3BoardPiece; if (applyFilter) { return(link.CanBeLink ? link : null); } else { return(link); } }