Beispiel #1
0
		private void MakeNextStep(Point? previousPoint, Step currentStep)
		{
			if (!currentStep.ActualPoint.Equals(previousPoint))
			{
				Step sameActualPointStep = mazePointsCollection.FirstOrDefault(obj => obj.ActualPoint.Equals(currentStep.ActualPoint));
				if (sameActualPointStep != null
					&& sameActualPointStep.Value <= currentStep.Value)
				{
					return;
				}
				else if (sameActualPointStep != null)
				{
					mazePointsCollection.Remove(sameActualPointStep);
				}
				NextStep(currentStep);
			}
		}
Beispiel #2
0
		private void NextStep(Step currentStep)
		{
			mazePointsCollection.Add(currentStep);
			Point currentPoint = currentStep.ActualPoint;
			int value = currentStep.Value + 1;
			if (currentPoint.Equals(endPoint))
				return;

			Point newPoint;
			if (!lineCollection.Any(obj => obj.StartX == currentPoint.X
			&& obj.EndX == currentPoint.X + 1
			&& obj.StartY == currentPoint.Y
			&& obj.EndY == currentPoint.Y)
			&& currentPoint.Y - 1 >= 0
			)
			{
				newPoint = new Point(currentPoint.X, currentPoint.Y - 1);
				MakeNextStep(currentStep.PreviousPoint, new Step()
				{
					PreviousPoint = currentPoint,
					ActualPoint = newPoint,
					Value = value
				});
			}
			if (!lineCollection.Any(obj => obj.StartX == currentPoint.X
			&& obj.EndX == currentPoint.X + 1
			&& obj.StartY == currentPoint.Y + 1
			&& obj.EndY == currentPoint.Y + 1)
			&& currentPoint.Y + 1 < height
			)
			{
				newPoint = new Point(currentPoint.X, currentPoint.Y + 1);
				MakeNextStep(currentStep.PreviousPoint, new Step()
				{
					PreviousPoint = currentPoint,
					ActualPoint = newPoint,
					Value = value
				});
			}
			if (!lineCollection.Any(obj => obj.StartX == currentPoint.X
			&& obj.EndX == currentPoint.X
			&& obj.StartY == currentPoint.Y
			&& obj.EndY == currentPoint.Y + 1)
			&& currentPoint.X - 1 >= 0
			)
			{
				newPoint = new Point(currentPoint.X - 1, currentPoint.Y);
				MakeNextStep(currentStep.PreviousPoint, new Step()
				{
					PreviousPoint = currentPoint,
					ActualPoint = newPoint,
					Value = value
				});
			}
			if (!lineCollection.Any(obj => obj.StartX == currentPoint.X + 1
			&& obj.EndX == currentPoint.X + 1
			&& obj.StartY == currentPoint.Y
			&& obj.EndY == currentPoint.Y + 1)
			&& currentPoint.X + 1 < width
			)
			{
				newPoint = new Point(currentPoint.X + 1, currentPoint.Y);
				MakeNextStep(currentStep.PreviousPoint, new Step()
				{
					PreviousPoint = currentPoint,
					ActualPoint = newPoint,
					Value = value
				});
			}
		}