当前位置: 首页>>代码示例>>C#>>正文


C# Pathfinding.Path类代码示例

本文整理汇总了C#中Pathfinding.Path的典型用法代码示例。如果您正苦于以下问题:C# Path类的具体用法?C# Path怎么用?C# Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Path类属于Pathfinding命名空间,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculatePath

 public void CalculatePath()
 {
     var pos = (target == null) ? targetPosition : (target.transform.position + targetPosition);
     p = ABPath.Construct (go.transform.position , pos , OnPathComplete); // create path from current position to closest/first node
     AstarPath.StartPath (p); //make the actual vector3 path which we'll use lateron.
     pUpdate = 0;
 }
开发者ID:kiriri,项目名称:playmaker-astar-actions,代码行数:7,代码来源:FsmFollowTargetHelper.cs

示例2: Apply

		public override void Apply (Path _p) {
			var p = _p as ABPath;

			// This modifier only supports ABPaths (doesn't make much sense for other paths anyway)
			if (p == null || p.vectorPath.Count == 0) return;

			if (p.vectorPath.Count == 1 && !addPoints) {
				// Duplicate first point
				p.vectorPath.Add(p.vectorPath[0]);
			}

			// Add instead of replacing points
			bool forceAddStartPoint, forceAddEndPoint;

			Vector3 pStart = Snap(p, exactStartPoint, true, out forceAddStartPoint);
			Vector3 pEnd = Snap(p, exactEndPoint, false, out forceAddEndPoint);

			// Add or replace the start point
			// Disable adding of points if the mode is SnapToNode since then
			// the first item in vectorPath will very likely be the same as the
			// position of the first node
			if ((forceAddStartPoint || addPoints) && exactStartPoint != Exactness.SnapToNode) {
				p.vectorPath.Insert(0, pStart);
			} else {
				p.vectorPath[0] = pStart;
			}

			if ((forceAddEndPoint || addPoints) && exactEndPoint != Exactness.SnapToNode) {
				p.vectorPath.Add(pEnd);
			} else {
				p.vectorPath[p.vectorPath.Count-1] = pEnd;
			}
		}
开发者ID:CCGLP,项目名称:Fast,代码行数:33,代码来源:StartEndModifier.cs

示例3: ApplyNow

 private void ApplyNow(Path somePath)
 {
     object obj = this.lockObject;
     lock (obj)
     {
         this.waitingForApply = false;
         AstarPath.OnPathPreSearch = (OnPathDelegate)Delegate.Remove(AstarPath.OnPathPreSearch, new OnPathDelegate(this.ApplyNow));
         this.InversePrevious();
         if (!this.destroyed)
         {
             int seed = this.seedGenerator.Next();
             this.rnd = new System.Random(seed);
             if (this.toBeApplied != null)
             {
                 int num = this.rnd.Next(this.randomStep);
                 for (int i = num; i < this.toBeApplied.Length; i += this.rnd.Next(1, this.randomStep))
                 {
                     this.toBeApplied[i].Penalty = (uint)((ulong)this.toBeApplied[i].Penalty + (ulong)((long)this.penalty));
                 }
             }
             this.prevPenalty = this.penalty;
             this.prevSeed = seed;
             this.prevNodes = this.toBeApplied;
         }
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:26,代码来源:AlternativePath.cs

示例4: ClearOnDestroy

		void ClearOnDestroy (Path p) {
			lock (lockObject) {
				AstarPath.OnPathPreSearch -= ClearOnDestroy;
				waitingForApply = false;
				InversePrevious();
			}
		}
开发者ID:CCGLP,项目名称:Fast,代码行数:7,代码来源:AlternativePath.cs

示例5: PathEndingCondition

 public PathEndingCondition(Path p)
 {
     if (p == null)
     {
         throw new ArgumentNullException("p");
     }
     this.path = p;
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:8,代码来源:PathEndingCondition.cs

示例6: OnPathComplete

		public void OnPathComplete (Path p) {
			//		Debug.Log ("Yay, we got a path back. Did it have an error? "+p.error);
			if (!p.error) {
				path = p;
				//Reset the waypoint counter
				currentWaypoint = 0;
			}
		}
开发者ID:pateldhruv1993,项目名称:Basic-RTS-Mechanics-Unity3D,代码行数:8,代码来源:FollowPathfinder.cs

示例7: Initialize

		/** Initializes the NodeRunData for calculation of the specified path.
		 * Called by core pathfinding functions just before starting to calculate a path.
		 */
		public void Initialize (Path p) {
			path = p;
			
			pathID = p.pathID;
			
			//Resets the binary heap, don't clear everything because that takes an awful lot of time, instead we can just change the numberOfItems in it (which is just an int)
			//Binary heaps are just like a standard array but are always sorted so the node with the lowest F value can be retrieved faster
			open.Clear ();
		}
开发者ID:JustSAT,项目名称:Tower-Defence,代码行数:12,代码来源:MultithreadClasses.cs

示例8: CompletePath

 void CompletePath(Pathfinding.Path p)
 {
     if (!p.error) {
         path = p;
         currentWayPoint = 1;
         if (p.vectorPath.Count == 1) currentWayPoint = 0;
         if (!animator.GetBool("Running")) animator.SetBool("Run",true);
     }
 }
开发者ID:Tairos,项目名称:PFP,代码行数:9,代码来源:Unit.cs

示例9: InSearchTree

 public static bool InSearchTree(GraphNode node, Path path)
 {
     if (path == null || path.pathHandler == null)
     {
         return true;
     }
     PathNode pathNode = path.pathHandler.GetPathNode(node);
     return pathNode.pathID == path.pathID;
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:9,代码来源:NavGraph.cs

示例10: OnPathComplete

 //当寻路结束后调用这个函数
 public void OnPathComplete(Path p)
 {
     Debug.Log("FindThePath" + p.error);
     //如果找到了一条路径,保存下来,并且把第一个路点设置为当前路点
     if (!p.error)
     {
         path = p;
         currentWaypoint = 0;
     }
 }
开发者ID:zs9024,项目名称:Jungle,代码行数:11,代码来源:BTActionPathFind.cs

示例11: GetTotalDistanceOfPath

 private float GetTotalDistanceOfPath(Path path)
 {
     var totalDistance = 0.0f;
     for (var i = 1; i < path.vectorPath.Count; i++)
     {
         var previousPosition = path.vectorPath[i - 1];
         var nextPosition = path.vectorPath[i];
         totalDistance = Vector3.Distance(previousPosition, nextPosition);
     }
     return totalDistance;
 }
开发者ID:grofit,项目名称:uFrame.ECS.Actions.AStarPathfinding,代码行数:11,代码来源:GetDistanceOfPathAction.cs

示例12: PathFinishedDelegate

        private void PathFinishedDelegate(Path path)
        {
            if (path.error)
            {
                Error = path.errorLog;
                PathFailed();
                return;
            }

            GeneratedPath = (ConstantPath) path;
            PathGenerated();
        }
开发者ID:grofit,项目名称:uFrame.ECS.Actions.AStarPathfinding,代码行数:12,代码来源:CreateConstantPathAction.cs

示例13: Apply

		public override void Apply (Path p) {
			if (this == null) return;

			lock (lockObject) {
				toBeApplied = p.path.ToArray();

				if (!waitingForApply) {
					waitingForApply = true;
					AstarPath.OnPathPreSearch += ApplyNow;
				}
			}
		}
开发者ID:CCGLP,项目名称:Fast,代码行数:12,代码来源:AlternativePath.cs

示例14: ChooseWaypoint

        void ChooseWaypoint()
        {
            if (waypoints.Length <= 2) {
                return;
            }

            destinationWaypoint = waypoints [UnityEngine.Random.Range (0, waypoints.Length - 1)];
            path = null;
            currentDirection = Vector3.zero;
            currentWaypointIndex = 0;
            seeker.StartPath (transform.position, destinationWaypoint.position, OnPathComplete);
        }
开发者ID:doctorpangloss,项目名称:Cordon2,代码行数:12,代码来源:PatientZeroController.cs

示例15: Apply

		public override void Apply (Path p) {
			List<GraphNode> path = p.path;
			List<Vector3> vectorPath = p.vectorPath;

			if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
				return;
			}

			List<Vector3> funnelPath = ListPool<Vector3>.Claim();

			// Claim temporary lists and try to find lists with a high capacity
			List<Vector3> left = ListPool<Vector3>.Claim(path.Count+1);
			List<Vector3> right = ListPool<Vector3>.Claim(path.Count+1);

			AstarProfiler.StartProfile("Construct Funnel");

			// Add start point
			left.Add(vectorPath[0]);
			right.Add(vectorPath[0]);

			// Loop through all nodes in the path (except the last one)
			for (int i = 0; i < path.Count-1; i++) {
				// Get the portal between path[i] and path[i+1] and add it to the left and right lists
				bool portalWasAdded = path[i].GetPortal(path[i+1], left, right, false);

				if (!portalWasAdded) {
					// Fallback, just use the positions of the nodes
					left.Add((Vector3)path[i].position);
					right.Add((Vector3)path[i].position);

					left.Add((Vector3)path[i+1].position);
					right.Add((Vector3)path[i+1].position);
				}
			}

			// Add end point
			left.Add(vectorPath[vectorPath.Count-1]);
			right.Add(vectorPath[vectorPath.Count-1]);

			if (!RunFunnel(left, right, funnelPath)) {
				// If funnel algorithm failed, degrade to simple line
				funnelPath.Add(vectorPath[0]);
				funnelPath.Add(vectorPath[vectorPath.Count-1]);
			}

			// Release lists back to the pool
			ListPool<Vector3>.Release(p.vectorPath);
			p.vectorPath = funnelPath;

			ListPool<Vector3>.Release(left);
			ListPool<Vector3>.Release(right);
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:52,代码来源:FunnelModifier.cs


注:本文中的Pathfinding.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。