本文整理汇总了C#中Pathfinding.Path.Claim方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Claim方法的具体用法?C# Path.Claim怎么用?C# Path.Claim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.Path
的用法示例。
在下文中一共展示了Path.Claim方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPathComplete
// Metodo que se llama cuando una ruta ha sido calculada
public void OnPathComplete (Path p) {
p.Claim (this);
if (!p.error) {
if (path != null) path.Release (this);
path = p;
currentWaypoint = 1;
} else {
p.Release (this);
Debug.Log ("No se puede llegar a este punto de destino: "+p.errorLog);
}
}
示例2: OnPathComplete
public void OnPathComplete(Path p)
{
p.Claim (this);
if (!p.error) {
if (path != null) path.Release (this);
path = p;
//Reset the waypoint counter
currentWaypoint = 0;
currentPathCount = path.vectorPath.Count;
} else {
p.Release (this);
Debug.Log ("The target was not reachable: "+p.errorLog);
}
}
示例3: OnPathComplete
public void OnPathComplete(Path p)
{
p.Claim (this);
if (!p.error) {
if (path != null) path.Release (this);
path = p;
//Reset the waypoint counter
currentAIWaypoint = 0;
} else {
p.Release (this);
//Debug.Log ("Oh noes, the target was not reachable: "+p.errorLog);
}
//seeker.StartPath (transform.position,targetPosition, OnPathComplete);
}
示例4: OnPathComplete
/** Called when a path has completed.
* Will post process it and return it by calling #tmpPathCallback and #pathCallback */
public void OnPathComplete (Path p, bool runModifiers, bool sendCallbacks) {
AstarProfiler.StartProfile ("Seeker OnPathComplete");
if (p != null && p != path && sendCallbacks) {
return;
}
if (this == null || p == null || p != path)
return;
if (!path.error && runModifiers) {
AstarProfiler.StartProfile ("Seeker Modifiers");
//This will send the path for post processing to modifiers attached to this Seeker
RunModifiers (ModifierPass.PostProcessOriginal, path);
//This will send the path for post processing to modifiers attached to this Seeker
RunModifiers (ModifierPass.PostProcess, path);
AstarProfiler.EndProfile ();
}
if (sendCallbacks) {
p.Claim (this);
AstarProfiler.StartProfile ("Seeker Callbacks");
lastCompletedNodePath = p.path;
lastCompletedVectorPath = p.vectorPath;
//This will send the path to the callback (if any) specified when calling StartPath
if (tmpPathCallback != null) {
tmpPathCallback (p);
}
//This will send the path to any script which has registered to the callback
if (pathCallback != null) {
pathCallback (p);
}
//Recycle the previous path
if (prevPath != null) {
prevPath.ReleaseSilent (this);
}
prevPath = p;
//If not drawing gizmos, then storing prevPath is quite unecessary
//So clear it and set prevPath to null
if (!drawGizmos) ReleaseClaimedPath ();
AstarProfiler.EndProfile();
}
AstarProfiler.EndProfile ();
}
示例5: StartPath
/** Puts the Path in queue for calculation.
* The callback specified when constructing the path will be called when the path has been calculated.
* Usually you should use the Seeker component instead of calling this function directly.
*
* \param p The path that should be put in queue for calculation
* \param pushToFront If true, the path will be pushed to the front of the queue, bypassing all waiting paths and making it the next path to be calculated.
* This can be useful if you have a path which you want to prioritize over all others. Be careful to not overuse it though.
* If too many paths are put in the front of the queue often, this can lead to normal paths having to wait a very long time before being calculated.
*/
public static void StartPath (Path p, bool pushToFront = false) {
if (active == null) {
Debug.LogError ("There is no AstarPath object in the scene");
return;
}
if (p.GetState() != PathState.Created) {
throw new System.Exception ("The path has an invalid state. Expected " + PathState.Created + " found " + p.GetState() + "\n" +
"Make sure you are not requesting the same path twice");
}
if (active.pathQueue.IsTerminating) {
p.Error ();
p.LogError ("No new paths are accepted");
return;
}
if (active.graphs == null || active.graphs.Length == 0) {
Debug.LogError ("There are no graphs in the scene");
p.Error ();
p.LogError ("There are no graphs in the scene");
Debug.LogError (p.errorLog);
return;
}
p.Claim (active);
//Will increment to PathQueue
p.AdvanceState (PathState.PathQueue);
if (pushToFront) {
active.pathQueue.PushFront (p);
} else {
active.pathQueue.Push (p);
}
}
示例6: OnPathComplete
public void OnPathComplete(Path p)
{
if(target == null)
{
p.Claim (this);
// Debug.Log ("Yey, we got a path back. Did it have an error? "+p.error);
if (!p.error) {
if (path != null) path.Release (this);
path = p;
//Reset the waypoint counter
currentWaypoint = 0;
}
else {
p.Release (this);
bChangeWaypoint = true;
Debug.Log ("Oh noes, the target was not reachable: "+p.errorLog);
}
}
else
{
/*if (Time.time-lastPathSearch >= repathRate) {
Repath ();
} else {*/
StartCoroutine (WaitToRepath ());
//}
p.Claim (this);
//If the path didn't succeed, don't proceed
if (p.error) {
p.Release (this);
return;
}
else
{
//if(path != null) path.Release (this);
//Get the calculated path as a Vector3 array
path2 = p.vectorPath.ToArray();
//Find the segment in the path which is closest to the AI
//If a closer segment hasn't been found in '6' iterations, break because it is unlikely to find any closer ones then
float minDist = Mathf.Infinity;
int notCloserHits = 0;
for (int i=0;i<path2.Length-1;i++) {
float dist = Mathfx.DistancePointSegmentStrict (path2[i],path2[i+1],tr.position);
if (dist < minDist) {
notCloserHits = 0;
minDist = dist;
pathIndex = i+1;
} else if (notCloserHits > 6) {
break;
}
}
}
}
}
示例7: StartPath
/** Puts the Path in queue for calculation.
* The callback specified when constructing the path will be called when the path has been calculated.
* Usually you should use the Seeker component instead of calling this function directly.
*/
public static void StartPath (Path p) {
if (active == null) {
Debug.LogError ("There is no AstarPath object in the scene");
return;
}
if (p.GetState() != PathState.Created) {
throw new System.Exception ("The path has an invalid state. Expected " + PathState.Created + " found " + p.GetState() + "\n" +
"Make sure you are not requesting the same path twice");
}
if (!active.acceptNewPaths) {
p.Error ();
p.LogError ("No new paths are accepted");
//Debug.LogError (p.errorLog);
//p.ReturnPath ();
return;
}
if (active.graphs == null || active.graphs.Length == 0) {
Debug.LogError ("There are no graphs in the scene");
p.Error ();
p.LogError ("There are no graphs in the scene");
Debug.LogError (p.errorLog);
//p.ReturnPath ();
return;
}
/*MultithreadPath p2 = p as MultithreadPath;
if (p2 == null) {
Debug.LogError ("Path Not Set Up For Multithreading");
return;
}*/
p.Claim (active);
lock (pathQueue) {
//Will increment to PathQueue
p.AdvanceState (PathState.PathQueue);
pathQueue.Enqueue (p);
if (doSetQueueState)
pathQueueFlag.Set ();
}
}
示例8: OnPathComplete
void OnPathComplete (Path p) {
waitingForPathCalc = false;
p.Claim(this);
if (p.error) {
p.Release(this);
return;
}
if (traversingSpecialPath) {
delayUpdatePath = true;
} else {
if (rp == null) rp = new RichPath();
rp.Initialize (seeker, p,true, funnelSimplification);
}
p.Release(this);
}
示例9: OnPathComplete
public void OnPathComplete(Path p)
{
//Debug.Log ("Error? -" + p.error);
if(!p.error) //if no error
{
path = p; //set path to correct path
currentNode = 0; //reset index
path.Claim(this);
}
else{
ToggleAttack(isPissed);
}
}
示例10: OnPathComplete
private void OnPathComplete(Path p, bool runModifiers, bool sendCallbacks)
{
if (p != null && p != this.path && sendCallbacks)
{
return;
}
if (this == null || p == null || p != this.path)
{
return;
}
if (!this.path.error && runModifiers)
{
this.RunModifiers(Seeker.ModifierPass.PostProcess, this.path);
}
if (sendCallbacks)
{
p.Claim(this);
this.lastCompletedNodePath = p.path;
this.lastCompletedVectorPath = p.vectorPath;
if (this.tmpPathCallback != null)
{
this.tmpPathCallback(p);
}
if (this.pathCallback != null)
{
this.pathCallback(p);
}
if (this.prevPath != null)
{
this.prevPath.ReleaseSilent(this);
}
this.prevPath = p;
if (!this.drawGizmos)
{
this.ReleaseClaimedPath();
}
}
}
示例11: OnPathingComplete
private void OnPathingComplete(Path path)
{
if (path.error == false)
{
if (_path != null)
{
_path.Release(this);
}
_path = path;
_path.Claim(this);
_pathIndex = 0;
//Update distanec to objective.
this.DistanceToObjective = _path.GetTotalLength();
}
}
示例12: OnPathComplete
private void OnPathComplete(Path p)
{
p.Claim(this);
if (!p.error) {
StopMoving();
isMoving = true;
path = p;
currentWaypoint = 0;
}
else {
p.Release(this);
isMoving = false;
}
}