本文整理汇总了C#中Pathfinding.Path.GetConnectionSpecialCost方法的典型用法代码示例。如果您正苦于以下问题:C# Path.GetConnectionSpecialCost方法的具体用法?C# Path.GetConnectionSpecialCost怎么用?C# Path.GetConnectionSpecialCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.Path
的用法示例。
在下文中一共展示了Path.GetConnectionSpecialCost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public override void Open (Path path, PathNode pathNode, PathHandler handler) {
if (connections == null) return;
bool flag2 = pathNode.flag2;
for (int i=connections.Length-1;i >= 0;i--) {
GraphNode other = connections[i];
if (path.CanTraverse (other)) {
PathNode pathOther = handler.GetPathNode (other);
//Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
if (pathOther == pathNode.parent) {
continue;
}
uint cost = connectionCosts[i];
if (flag2 || pathOther.flag2) {
cost = path.GetConnectionSpecialCost (this,other,cost);
}
if (pathOther.pathID != handler.PathID) {
//Might not be assigned
pathOther.node = other;
pathOther.parent = pathNode;
pathOther.pathID = handler.PathID;
pathOther.cost = cost;
pathOther.H = path.CalculateHScore (other);
other.UpdateG (path, pathOther);
handler.PushNode (pathOther);
} else {
//If not we can test if the path from this node to the other one is a better one than the one already used
if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G) {
pathOther.cost = cost;
pathOther.parent = pathNode;
other.UpdateRecursiveG (path, pathOther,handler);
//handler.PushNode (pathOther);
}
else if (pathOther.G+cost+path.GetTraversalCost(this) < pathNode.G && other.ContainsConnection (this)) {
//Or if the path from the other node to this one is better
pathNode.parent = pathOther;
pathNode.cost = cost;
UpdateRecursiveG (path, pathNode,handler);
//handler.PushNode (pathNode);
}
}
}
}
}
示例2: Open
public override void Open (Path path, PathNode pathNode, PathHandler handler) {
if (connections == null) return;
// Flag2 indicates if this node needs special treatment
// with regard to connection costs
bool flag2 = pathNode.flag2;
// Loop through all connections
for (int i=connections.Length-1;i >= 0;i--) {
GraphNode other = connections[i];
// Make sure we can traverse the neighbour
if (path.CanTraverse (other)) {
PathNode pathOther = handler.GetPathNode (other);
// Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
if (pathOther == pathNode.parent) {
continue;
}
uint cost = connectionCosts[i];
if (flag2 || pathOther.flag2) {
// Get special connection cost from the path
// This is used by the start and end nodes
cost = path.GetConnectionSpecialCost (this,other,cost);
}
// Test if we have seen the other node before
if (pathOther.pathID != handler.PathID) {
// We have not seen the other node before
// So the path from the start through this node to the other node
// must be the shortest one so far
// Might not be assigned
pathOther.node = other;
pathOther.parent = pathNode;
pathOther.pathID = handler.PathID;
pathOther.cost = cost;
pathOther.H = path.CalculateHScore (other);
other.UpdateG (path, pathOther);
handler.PushNode (pathOther);
} else {
// If not we can test if the path from this node to the other one is a better one than the one already used
if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G) {
pathOther.cost = cost;
pathOther.parent = pathNode;
other.UpdateRecursiveG (path, pathOther,handler);
}
else if (pathOther.G+cost+path.GetTraversalCost(this) < pathNode.G && other.ContainsConnection (this)) {
// Or if the path from the other node to this one is better
pathNode.parent = pathOther;
pathNode.cost = cost;
UpdateRecursiveG (path, pathNode,handler);
}
}
}
}
}
示例3: Open
public override void Open(Path path, PathNode pathNode, PathHandler handler)
{
if (this.connections == null)
{
return;
}
bool flag = pathNode.flag2;
for (int i = this.connections.Length - 1; i >= 0; i--)
{
GraphNode graphNode = this.connections[i];
if (path.CanTraverse(graphNode))
{
PathNode pathNode2 = handler.GetPathNode(graphNode);
if (pathNode2 != pathNode.parent)
{
uint num = this.connectionCosts[i];
if (flag || pathNode2.flag2)
{
num = path.GetConnectionSpecialCost(this, graphNode, num);
}
if (pathNode2.pathID != handler.PathID)
{
pathNode2.node = graphNode;
pathNode2.parent = pathNode;
pathNode2.pathID = handler.PathID;
pathNode2.cost = num;
pathNode2.H = path.CalculateHScore(graphNode);
graphNode.UpdateG(path, pathNode2);
handler.PushNode(pathNode2);
}
else if (pathNode.G + num + path.GetTraversalCost(graphNode) < pathNode2.G)
{
pathNode2.cost = num;
pathNode2.parent = pathNode;
graphNode.UpdateRecursiveG(path, pathNode2, handler);
}
else if (pathNode2.G + num + path.GetTraversalCost(this) < pathNode.G && graphNode.ContainsConnection(this))
{
pathNode.parent = pathNode2;
pathNode.cost = num;
this.UpdateRecursiveG(path, pathNode, handler);
}
}
}
}
}