本文整理汇总了C#中OnPathDelegate类的典型用法代码示例。如果您正苦于以下问题:C# OnPathDelegate类的具体用法?C# OnPathDelegate怎么用?C# OnPathDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnPathDelegate类属于命名空间,在下文中一共展示了OnPathDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
protected void Setup (Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback) {
inverted = false;
this.callback = callback;
callbacks = callbackDelegates;
targetPoints = targets;
originalStartPoint = start;
//originalEndPoint = end;
startPoint = start;
startIntPoint = (Int3)start;
if (targets.Length == 0) {
Error ();
LogError ("No targets were assigned to the MultiTargetPath");
return;
}
endPoint = targets[0];
originalTargetPoints = new Vector3[targetPoints.Length];
for (int i=0;i<targetPoints.Length;i++) {
originalTargetPoints[i] = targetPoints[i];
}
}
示例2: Construct
public static FloodPath Construct (GraphNode start, OnPathDelegate callback = null) {
if (start == null) throw new ArgumentNullException("start");
var p = PathPool.GetPath<FloodPath>();
p.Setup(start, callback);
return p;
}
示例3: Construct
public new static XPath Construct (Vector3 start, Vector3 end, OnPathDelegate callback = null) {
var p = PathPool.GetPath<XPath>();
p.Setup(start, end, callback);
p.endingCondition = new ABPathEndingCondition(p);
return p;
}
示例4: Setup
protected void Setup(Vector3 start, Vector3 avoid, int searchLength, OnPathDelegate callback)
{
Setup (start, searchLength, callback);
aim = avoid-start;
aim *= 10;
aim = start - aim;
}
示例5: Setup
/** Sets up a ConstantPath starting from the specified point */
protected void Setup (Vector3 start, int maxGScore, OnPathDelegate callback) {
this.callback = callback;
startPoint = start;
originalStartPoint = startPoint;
endingCondition = new EndingConditionDistance (this,maxGScore);
}
示例6: RandomPath
public RandomPath(Vector3 start, int length, OnPathDelegate callbackDelegate = null)
{
callTime = System.DateTime.Now;
callback = callbackDelegate;
searchLength = length;
if (AstarPath.active == null || AstarPath.active.graphs == null) {
errorLog += "No NavGraphs have been calculated yet - Don't run any pathfinding calls in Awake";
if (AstarPath.active.logPathResults != PathLog.None) {
Debug.LogError (errorLog);
}
error = true;
return;
}
pathID = AstarPath.active.GetNextPathID ();
originalStartPoint = start;
originalEndPoint = Vector3.zero;
startPoint = start;
endPoint = Vector3.zero;
startIntPoint = (Int3)start;
hTarget = (Int3)aim;//(Int3)(start-aim);//new Int3(0,0,0);
rnd = new System.Random ();
}
示例7: FloodPathTracer
public FloodPathTracer(Vector3 start, FloodPath flood, OnPathDelegate callbackDelegate)
: base(start,flood.originalStartPoint,callbackDelegate)
{
this.flood = flood;
if (flood == null || !flood.processed)
throw new System.ArgumentNullException ("You must supply a calculated FloodPath to the 'flood' argument");
hasEndPoint = false;
nnConstraint = new PathIDConstraint ();
}
示例8: Setup
protected void Setup (Vector3 start, FloodPath flood, OnPathDelegate callback) {
this.flood = flood;
if (flood == null || flood.GetState () < PathState.Returned) {
throw new System.ArgumentException ("You must supply a calculated FloodPath to the 'flood' argument");
}
base.Setup (start, flood.originalStartPoint, callback);
nnConstraint = new FloodPathConstraint (flood);
}
示例9: FleePath
public FleePath(Vector3 start, Vector3 avoid, int length, OnPathDelegate callbackDelegate = null)
: base(start,length,callbackDelegate)
{
/*if (AstarPath.active.heuristicScale == 0) {
heuristicScale = -1;
} else {
heuristicScale = System.Math.Abs (AstarPath.active.heuristicScale) * -1;
}*/
originalEndPoint = avoid;
endPoint = avoid;
searchLength = length;
hTarget = (Int3)avoid;
}
示例10: MultiTargetPath
public MultiTargetPath(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callbackDelegate = null)
{
inverted = false;
callback = callbackDelegate;
callbacks = callbackDelegates;
pathID = AstarPath.active.GetNextPathID ();
if (AstarPath.active == null || AstarPath.active.graphs == null) {
errorLog += "No NavGraphs have been calculated yet - Don't run any pathfinding calls in Awake";
if (AstarPath.active.logPathResults != PathLog.None) {
Debug.LogError (errorLog);
}
error = true;
return;
}
targetPoints = targets;
originalStartPoint = start;
//originalEndPoint = end;
startPoint = start;
startIntPoint = (Int3)start;
if (targets.Length == 0) {
error = true;
errorLog += "No targets were assigned\n";
return;
}
endPoint = targets[0];
originalTargetPoints = new Vector3[targetPoints.Length];
for (int i=0;i<targetPoints.Length;i++) {
originalTargetPoints[i] = targetPoints[i];
}
//heuristic = Heuristic.Euclidean;//Heuristic.None;
//heuristicScale = 1F;
}
示例11: StartPath
/** Call this function to start calculating a path.
* \param p The path to start calculating
* \param callback The function to call when the path has been calculated
* \param graphMask Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask. \astarproParam
*
* \a callback will be called when the path has completed.
* \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed) */
public Path StartPath (Path p, OnPathDelegate callback = null, int graphMask = -1) {
p.enabledTags = traversableTags.tagsChange;
p.tagPenalties = tagPenalties;
//Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
if (path != null && path.GetState() <= PathState.Processing && lastPathID == path.pathID) {
path.LogError ("Canceled path because a new one was requested\nGameObject: "+gameObject.name);
//No callback should be sent for the canceled path
}
path = p;
path.callback += onPathDelegate;
tmpPathCallback = callback;
//Set the Get Nearest Node hints if they have not already been set
/*if (path.startHint == null)
path.startHint = startHint;
if (path.endHint == null)
path.endHint = endHint;
*/
//Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
lastPathID = path.pathID;
//Delay the path call by one frame if it was sent the same frame as the previous call
/*if (lastPathCall == Time.frameCount) {
StartCoroutine (DelayPathStart (path));
return path;
}*/
//lastPathCall = Time.frameCount;
//Pre process the path
RunModifiers (ModifierPass.PreProcess, path);
//Send the request to the pathfinder
AstarPath.StartPath (path);
return path;
}
示例12: XPath
public XPath(Vector3 start, Vector3 end, OnPathDelegate callbackDelegate)
{
Setup (start, end, callbackDelegate);
}
示例13: Reset
public virtual void Reset(Vector3 start, Vector3 end, OnPathDelegate callbackDelegate, bool reset = true)
{
if (reset)
{
processed = false;
vectorPath = null;
path = null;
next = null;
foundEnd = false;
error = false;
errorLog = "";
callback = null;
current = null;
duration = 0;
searchIterations = 0;
searchedNodes = 0;
startHint = null;
endHint = null;
}
callTime = System.DateTime.Now;
callback = callbackDelegate;
if (AstarPath.active == null || AstarPath.active.graphs == null)
{
errorLog += "No NavGraphs have been calculated yet - Don't run any pathfinding calls in Awake";
if (AstarPath.active.logPathResults != PathLog.None)
{
Debug.LogWarning(errorLog);
}
error = true;
return;
}
pathID = AstarPath.active.GetNextPathID();
UpdateStartEnd(start, end);
heuristic = AstarPath.active.heuristic;
heuristicScale = AstarPath.active.heuristicScale;
}
示例14: XPath
public XPath (Vector3 start, Vector3 end, OnPathDelegate callbackDelegate) : base (start,end,callbackDelegate) {}
示例15: StartMultiTargetPath
/** Starts a Multi Target Path. Takes a MultiTargetPath and wires everything up for it to send callbacks to the seeker for post-processing.\n
* \param p The path to start calculating
* \param callback The function to call when the path has been calculated
* \param graphMask Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask. \astarproParam
*
* \a callback and #pathCallback will be called when the path has completed. \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
* \astarpro
* \see Pathfinding.MultiTargetPath
* \see \ref MultiTargetPathExample.cs "Example of how to use multi-target-paths"
*/
public MultiTargetPath StartMultiTargetPath (MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1) {
//Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
if (path != null && path.GetState () <= PathState.Processing && lastPathID == path.pathID) {
path.ForceLogError ("Canceled path because a new one was requested");
//No callback should be sent for the canceled path
}
OnPathDelegate[] callbacks = new OnPathDelegate[p.targetPoints.Length];
for (int i=0;i<callbacks.Length;i++) {
callbacks[i] = onPartialPathDelegate;
}
p.callbacks = callbacks;
p.callback += OnMultiPathComplete;
p.nnConstraint.graphMask = graphMask;
path = p;
tmpPathCallback = callback;
//Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
lastPathID = path.pathID;
//Delay the path call by one frame if it was sent the same frame as the previous call
/*if (lastPathCall == Time.frameCount) {
StartCoroutine (DelayPathStart (path));
return p;
}
lastPathCall = Time.frameCount;*/
//Pre process the path
RunModifiers (ModifierPass.PreProcess, path);
//Send the request to the pathfinder
AstarPath.StartPath (path);
return p;
}