private async void Mouse_ButtonDown(object sender, MouseButtonEventArgs e) { var targetPos = Camera.GetWorldPos(e.Pos); var request = PathfinderComponent.Pathfinder.RequestPath(GameObj.Transform.Pos, targetPos, CollisionCategory, AgentSize); _path = await request; }
public static bool IsLast(this IWaypointPath path, IWaypoint waypoint) { if (path.Count > 0 && waypoint == path[path.Count - 1]) { return(true); } return(false); }
/// <summary> /// Removes all waypoints on the path ahead of <paramref name="waypoint"/>. /// </summary> /// <param name="path">The current waypoint path.</param> /// <param name="waypoint">The waypoint from which to remove waypoints from.</param> public static void TrimAhead(this IWaypointPath path, IWaypoint waypoint) { var startIndex = path.GetIndexOf(waypoint); for (var i = startIndex + 1; i < path.Count; i++) { path.RemoveAtIndex(i); } }
public static void DrawGizmos(this IWaypointPath path) { Gizmos.color = Color.grey; for (var i = 0; i < path.Count; i++) { Gizmos.DrawSphere(path[i].Position, 0.25f); } }
public void Follow(IWaypointPath path) { this.Path = path; this.Path.OnWaypointAdded += waypoint => { // this.WaypointAdded(waypoint); this.logger.Trace("New waypoint added to path", x => x .Field(LogNumWaypointsKey, this.Path.Count) .Field(LogWaypointKey, waypoint)); // TODO: probably don't need to explicity check the current fsm state. It will respect the transition table. if (this.fsm.CurrentState == WaypointPathMoverFsm.FsmStateKind.Idle) { this.fsm.TriggerWaypointAdded(); } }; }
public static void AddSpiral(this IWaypointPath path, Vector3 startPos, Vector3 pivot, float endDistance, float endHeight, float stepAngle = 10f, int numSteps = 36) { var offset = startPos - Math3d.ProjectPointOnLine(pivot, Vector3.up, startPos); var dir = offset.normalized; var startD = offset.magnitude; var startH = startPos.y; var p = startPos; for (var i = 0; i < numSteps; i++) { var t = 1f / numSteps * i; var d = Mathf.Lerp(startD, endDistance, t); var h = Mathf.Lerp(startH, endHeight, t); p = Quaternion.Euler(0f, i * stepAngle, 0f) * dir * d; p += Vector3.up * h; path.Add(new Waypoint(p)); } }
public WaypointPathTweenCurve(string propName, Ease ease, float dur, IWaypointPath path) : base(propName, ease, dur) { _path = path; }
/// <summary> /// Checks if the specified waypoint has another waypoint after it. /// </summary> /// <returns><c>true</c> if there is a next waypoint, or if the specified waypoint is null; otherwise, <c>false</c>.</returns> /// <param name="path">The path to check.</param> /// <param name="waypoint">The waypoint to check for a next waypoint.</param> public static bool HasNext(this IWaypointPath path, IWaypoint waypoint) { IWaypoint next; return(path.TryGetNext(waypoint, out next)); }
public WaypointPathMovePlanStep(IWaypointPath path) { this.Path = path; }
void Awake() { this.path = new WaypointPath(); this.PathMover = this.GetComponent <IWaypointPathMover>(); }