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;
        }
Exemple #2
0
        public static bool IsLast(this IWaypointPath path, IWaypoint waypoint)
        {
            if (path.Count > 0 && waypoint == path[path.Count - 1])
            {
                return(true);
            }

            return(false);
        }
Exemple #3
0
        /// <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);
            }
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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();
                }
            };
        }
Exemple #6
0
        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));
            }
        }
Exemple #7
0
 public WaypointPathTweenCurve(string propName, Ease ease, float dur, IWaypointPath path)
     : base(propName, ease, dur)
 {
     _path = path;
 }
Exemple #8
0
        /// <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));
        }
Exemple #9
0
 public WaypointPathMovePlanStep(IWaypointPath path)
 {
     this.Path = path;
 }
Exemple #10
0
 void Awake()
 {
     this.path      = new WaypointPath();
     this.PathMover = this.GetComponent <IWaypointPathMover>();
 }