private static Segment[] GetSegments(Polygon polygon) { polygon.FillVertexArray(); Segment polygonSegment; Segment[] segments = new Segment[polygon.Points.Count - 1]; for (int i = 0; i < polygon.Points.Count - 1; i++) { Vector3 vectorAtI = polygon.AbsolutePointPosition(i); polygonSegment = new Segment(vectorAtI, polygon.AbsolutePointPosition(i + 1)); segments[i] = polygonSegment; } return(segments); }
private static Segment[] GetSegments(Polygon polygon) { polygon.FillVertexArray(); Segment polygonSegment; Segment[] segments = new Segment[polygon.Points.Count - 1]; for (int i = 0; i < polygon.Points.Count - 1; i++) { Vector3 vectorAtI = polygon.AbsolutePointPosition(i); polygonSegment = new Segment(vectorAtI, polygon.AbsolutePointPosition(i + 1)); segments[i] = polygonSegment; } return segments; }
private void UpdateNavigationTargetProgress() { _currentDistanceToNavigationTarget = Vector3.Distance(Position, _targetPointForNavigation); if (_currentDistanceToNavigationTarget < DistanceToAchievePoint) { ChoosePointForNavigation(); _currentDistanceToNavigationTarget = Vector3.Distance(Position, _targetPointForNavigation); } else if (!IsFlying && PathingPointIndex < PathingLine.Points.Count - 1) { var currentSegment = PathingSegments[PathingPointIndex - 1]; var nextSegment = PathingSegments[PathingPointIndex]; if (currentSegment.DistanceTo(Position) > nextSegment.DistanceTo(Position)) { _targetPointForNavigation = PathingLine.AbsolutePointPosition(++PathingPointIndex); } } if (X + DistanceToAchievePoint > Camera.Main.OrthogonalWidth / 2) { HasReachedGoal = true; } }