private void TraverseNextEdge() { if (PathToFollow == null) { return; } ////TODO: probably should add NextEdge method to Path class PathEdge edgeToFollow = PathToFollow.Dequeue(); if (edgeToFollow == null) { return; } if (PathToFollow.IsEmpty) // last edge { edgeTraverser.Traverse( edgeToFollow, BrakeOnFinalApproach, StopOnFinalArrival); } else { edgeTraverser.Traverse( edgeToFollow, BrakeOnEachApproach, StopOnEachArrival); } }
private void StopIfFollowingPath() { if (PathToFollow != null) { PathToFollow.ShowPath(false); if (IsFollowing) { IsFollowing = false; // TODO: Perhaps this should be a FollowCancelled event EventManager.Instance.Enqueue <FollowCompletedEventPayload>( Events.FollowCompleted, new FollowCompletedEventPayload(gameObject, PathToFollow)); } } }
/// <summary> /// Checks if the controlled unit has reached the end of the path it is following /// Strategy: increase distance tolerance if there are many units in the area /// & check if the path "param" hasn't changed much in the past few seconds /// </summary> /// <returns></returns> public bool HasArrived() { return(Vector2.Distance(PathToFollow.GetPoint(PathToFollow.PointCount() - 1), ControlledUnit.Position) < 1.0f); }