/// <summary> /// This method is used to add the ladder on the board. This method doesn't check the start and end point rules. /// It will assume that the start and end points are already checked for possible errors and rules. /// This method will check only the intersection of new ladder with other already drawn ladders. /// </summary> /// <param name="start">Start point from which the ladder will start.</param> /// <param name="end">End point upto which the ladder will go.</param> /// <param name="checkIsIntersecting">If this argument is true, then before adding the ladder, it will be checked for intersection with other ladders. /// Else, it will be directly added to the board.</param> /// <returns>True if the ladder is added to the board, else false.</returns> public bool AddLadder(Point start, Point end, bool checkIsIntersecting = true) { Ladder ladder = new Ladder(); ladder.LadderColor = _LadderColor; ladder.LadderWidth = Math.Sqrt(GameBoard.Boxes[1].BoxTextBlock.ActualWidth * GameBoard.Boxes[1].BoxTextBlock.ActualWidth + GameBoard.Boxes[1].BoxTextBlock.ActualHeight * GameBoard.Boxes[1].BoxTextBlock.ActualHeight); ladder.StepsDifference = GameBoard.ActualWidth / _dbStepDifferenceFactor; ladder.LineThickness = GameBoard.ActualWidth / _dbLadderLineThicknessFactor; ladder.CanvasHeight = GameBoard.ActualHeight; ladder.CanvasWidth = GameBoard.ActualWidth; ladder.DrawLadder(start, end); if (!checkIsIntersecting || !IsIntersecting(ladder)) { BoardCanvas.Children.Add(ladder); _ladders.Add(ladder); return(true); } return(false); }