本文整理汇总了C#中NodeRecord类的典型用法代码示例。如果您正苦于以下问题:C# NodeRecord类的具体用法?C# NodeRecord怎么用?C# NodeRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeRecord类属于命名空间,在下文中一共展示了NodeRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NodeRecordArray
public NodeRecordArray(List<NavigationGraphNode> nodes, BoundingBox mapSize)
{
//this method creates and initializes the NodeRecordArray for all nodes in the Navigation Graph
this.NodeRecords = new NodeRecord[nodes.Count];
for (int i = 0; i < nodes.Count; i++)
{
var node = nodes[i];
#pragma warning disable 0618 //NodeIndex is deprecated
node.NodeIndex = i; //we're setting the node Index because RAIN does not do this automatically
#pragma warning restore 0618
NodeRecord nodeRecord = new NodeRecord { node = node,
status = NodeStatus.Unvisited
};
nodeRecord.edgeBounds = new BoundingBox[node.OutEdgeCount];
for (int j = 0; j < nodeRecord.edgeBounds.Length; j++)
{
BoundingBox boundingBox = new BoundingBox();
boundingBox.maxX = mapSize.minX;
boundingBox.maxZ = mapSize.minZ;
boundingBox.minX = mapSize.maxX;
boundingBox.minZ = mapSize.maxZ;
nodeRecord.edgeBounds[j] = boundingBox;
}
this.NodeRecords[i] = nodeRecord;
}
this.SpecialCaseNodes = new List<NodeRecord>();
this.Open = new NodePriorityHeap();
}
示例2: flood
public void flood(NodeRecord startingNode) {
NodeRecords.clearRecord();
startingNode.parent = null;
startingNode.edgeFromStart = -1;
startingNode.fValue = 0;
startingNode.status = NodeStatus.Open;
initializeFlood(startingNode);
startingNode.status = NodeStatus.Closed;
while (NodeRecords.CountOpen() > 0) {
var currentNode = NodeRecords.GetBestAndRemove();
for (int i = 0; i < currentNode.node.OutEdgeCount; i++)
{
NodeRecord childNode = this.NodeRecords.GetNodeRecord(currentNode.node.EdgeOut(i).ToNode);
this.pushNode(childNode, currentNode, currentNode.edgeFromStart,
currentNode.fValue + (currentNode.node.Position - childNode.node.Position).magnitude);
}
currentNode.status = NodeStatus.Closed;
}
}
示例3: SearchInClosed
public NodeRecord SearchInClosed(NodeRecord nodeRecord)
{
var storedNode = this.GetNodeRecord(nodeRecord.node);
if (storedNode != null && storedNode.status == NodeStatus.Closed) return storedNode;
else return null;
}
示例4: SearchInClosed
public NodeRecord SearchInClosed(NavigationGraphNode key, NodeRecord nodeRecord)
{
if (this.NodeRecords.Keys.Contains(key))
return (NodeRecord)this.NodeRecords[key];
else
return null;
}
示例5: Search
public NodeRecord Search(NodeRecord nodeRecord)
{
//here I cannot use the == comparer because the nodeRecord will likely be a different computational object
//and therefore pointer comparison will not work, we need to use Equals
//LINQ with a lambda expression
return this.NodeRecords.FirstOrDefault(n => n.Equals(nodeRecord));
}
示例6: RemoveFromOpen
public void RemoveFromOpen(NodeRecord nodeRecord)
{
int index = this.Open.BinarySearch(nodeRecord);
if (index >= 0)
{
this.Open.RemoveAt(index);
}
}
示例7: AddToOpen
public void AddToOpen(NodeRecord nodeRecord)
{
int index = this.Open.BinarySearch(nodeRecord);
if (index < 0)
{
this.Open.Insert(~index, nodeRecord);
}
}
示例8: SearchInClosed
public NodeRecord SearchInClosed(NodeRecord nodeRecord)
{
if (this.Closed.ContainsKey(nodeRecord.node))
{
return this.Closed[nodeRecord.node];
}
else return null;
}
示例9: initializeFlood
private void initializeFlood(NodeRecord startingNode)
{
for (int i = 0; i < startingNode.node.OutEdgeCount; i++) {
NodeRecord nodeRecord = this.NodeRecords.GetNodeRecord(startingNode.node.EdgeOut(i).ToNode);
this.pushNode(nodeRecord, startingNode, i, (startingNode.node.Position - nodeRecord.node.Position).magnitude);
}
}
示例10: Replace
public void Replace(NodeRecord nodeToBeReplaced, NodeRecord nodeToReplace)
{
//since the list is not ordered we do not need to remove the node and add the new one, just copy the different values
//remember that if NodeRecord is a struct, for this to work we need to receive a reference
nodeToBeReplaced.parent = nodeToReplace.parent;
nodeToBeReplaced.fValue = nodeToReplace.fValue;
nodeToBeReplaced.gValue = nodeToReplace.gValue;
nodeToBeReplaced.hValue = nodeToReplace.hValue;
}
示例11: ProcessChildNode
protected new void ProcessChildNode(NodeRecord bestNode, NavigationGraphEdge connectionEdge)
{
float f;
float g;
float h;
var childNode = connectionEdge.ToNode;
var childNodeRecord = this.NodeRecordArray.GetNodeRecord(childNode);
if (childNodeRecord == null)
{
//this piece of code is used just because of the special start nodes and goal nodes added to the RAIN Navigation graph when a new search is performed.
//Since these special goals were not in the original navigation graph, they will not be stored in the NodeRecordArray and we will have to add them
//to a special structure
//it's ok if you don't understand this, this is a hack and not part of the NodeArrayA* algorithm
childNodeRecord = new NodeRecord
{
node = childNode,
parent = bestNode,
status = NodeStatus.Unvisited
};
this.NodeRecordArray.AddSpecialCaseNode(childNodeRecord);
}
// implement the rest of your code here
if (childNodeRecord.status == NodeStatus.Closed) return;
float influenceCost = CalculateInfluenceCost(bestNode.node, childNode);
if (influenceCost < 0.0f)
return;
g = bestNode.gValue + connectionEdge.Cost - influenceCost;
h = this.Heuristic.H(childNode, this.GoalNode);
f = F(g,h);
if (childNodeRecord.status == NodeStatus.Open)
{
if (f <= childNodeRecord.fValue)
{
childNodeRecord.gValue = g;
childNodeRecord.hValue = h;
childNodeRecord.fValue = f;
childNodeRecord.parent = bestNode;
this.NodeRecordArray.Replace(childNodeRecord,childNodeRecord);
}
}
else
{
childNodeRecord.gValue = g;
childNodeRecord.hValue = h;
childNodeRecord.fValue = f;
childNodeRecord.status = NodeStatus.Open;
childNodeRecord.parent = bestNode;
this.NodeRecordArray.AddToOpen(childNodeRecord);
}
}
示例12: SearchInOpen
public NodeRecord SearchInOpen(NodeRecord nodeRecord)
{
int index = this.Open.BinarySearch(nodeRecord);
if (index >= 0)
{
return this.Open[index];
}
return null;
}
示例13: SearchInOpen
public NodeRecord SearchInOpen(NavigationGraphNode key, NodeRecord nodeRecord)
{
int index = this.Open.BinarySearch(nodeRecord);
if (index >= 0)
{
return this.Open[index];
}
return Open.FirstOrDefault(n => n.Equals(nodeRecord));
}
示例14: SearchInClosed
public NodeRecord SearchInClosed(NodeRecord nodeRecord)
{
//here I cannot use the == comparer because the nodeRecord will likely be a different computational object
//and therefore pointer comparison will not work, we need to use Equals
//LINQ with a lambda expression
if (this.NodeRecords.ContainsKey(nodeRecord.node)){
return this.NodeRecords[nodeRecord.node];
}
return null;
}
示例15: SearchInOpen
public NodeRecord SearchInOpen(NodeRecord nodeRecord)
{
//int index = this.Open.BinarySearch(nodeRecord);
//if (index < 0)
//{
// return null;
//}
//else return Open[index];
return this.Open.FirstOrDefault(n => n.Equals(nodeRecord));
}