private Turn GetTurn( Dictionary <ScaffoldPoint, PointType> map, ScaffoldPoint currentPoint, Direction currentDirection) { var turns = new[] { Turn.Left, Turn.Right }; foreach (var turn in turns) { var point = currentPoint.GetPoint(GetDirection(currentDirection, turn)); if (map.TryGetValue(point, out var type) && type == PointType.Scaffold) { return(turn); } } return(Turn.None); }
private (int counter, ScaffoldPoint) GetCount( Dictionary <ScaffoldPoint, PointType> map, ScaffoldPoint currentPoint, Direction newDirection) { var counter = 0; var point = currentPoint; point = point.GetPoint(newDirection); while (map.TryGetValue(point, out var type) && type == PointType.Scaffold) { counter++; point = point.GetPoint(newDirection); } var reverse = GetDirection(newDirection, Turn.Left); reverse = GetDirection(reverse, Turn.Left); return(counter, point.GetPoint(reverse)); }