• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NodeRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



NodeRecord类属于命名空间,在下文中一共展示了NodeRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:34,代码来源:NodeRecordArray.cs


示例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;
            }
           
        }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:27,代码来源:DijkstraFloodfill.cs


示例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;
        }
开发者ID:IAJ-g04,项目名称:Project4,代码行数:7,代码来源:NodeRecordArray.cs


示例4: SearchInClosed

 public NodeRecord SearchInClosed(NavigationGraphNode key, NodeRecord nodeRecord)
 {
     if (this.NodeRecords.Keys.Contains(key))
         return (NodeRecord)this.NodeRecords[key];
     else
         return null;
 }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:7,代码来源:NodeHashMap.cs


示例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));
 }
开发者ID:RicardoEPRodrigues,项目名称:IAJ-Labs,代码行数:7,代码来源:SimpleUnorderedNodeList.cs


示例6: RemoveFromOpen

 public void RemoveFromOpen(NodeRecord nodeRecord)
 {
     int index = this.Open.BinarySearch(nodeRecord);
     if (index >= 0)
     {
         this.Open.RemoveAt(index);
     }
 }
开发者ID:RicardoEPRodrigues,项目名称:IAJ-Project,代码行数:8,代码来源:LeftPriorityList.cs


示例7: AddToOpen

 public void AddToOpen(NodeRecord nodeRecord)
 {
     int index = this.Open.BinarySearch(nodeRecord);
     if (index < 0)
     {
         this.Open.Insert(~index, nodeRecord);
     }
 }
开发者ID:IAJ-g04,项目名称:Lab9,代码行数:8,代码来源:LeftPriorityList.cs


示例8: SearchInClosed

 public NodeRecord SearchInClosed(NodeRecord nodeRecord)
 {
     if (this.Closed.ContainsKey(nodeRecord.node))
     {
         return this.Closed[nodeRecord.node];
     }
     else return null;
 }
开发者ID:IAJ-g04,项目名称:Lab9,代码行数:8,代码来源:ClosedDictionary.cs


示例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);
     }
 }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:8,代码来源:DijkstraFloodfill.cs


示例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;
 }
开发者ID:miguelfmp,项目名称:IAJ---Projectos,代码行数:9,代码来源:DictionaryData.cs


示例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);
            }
        }
开发者ID:IAJ-g04,项目名称:Lab9,代码行数:57,代码来源:InfluenceMapAStarPathfinding.cs


示例12: SearchInOpen

 public NodeRecord SearchInOpen(NodeRecord nodeRecord)
 {
     int index = this.Open.BinarySearch(nodeRecord);
     if (index >= 0)
     {
         return this.Open[index];
     }
     return null;
 }
开发者ID:miguelfmp,项目名称:IAJ---Projectos,代码行数:9,代码来源:LeftPriorityList.cs


示例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)); 
 }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:9,代码来源:LeftPriorityList.cs


示例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;
 }
开发者ID:miguelfmp,项目名称:IAJ---Projectos,代码行数:10,代码来源:DictionaryData.cs


示例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));
 }
开发者ID:RicardoEPRodrigues,项目名称:IAJ-Project,代码行数:10,代码来源:LeftPriorityList.cs


示例16: SearchInOpen

 public NodeRecord SearchInOpen(NodeRecord nodeRecord)
 {
     if (NodeRecords[nodeRecord.node.NodeIndex].status == NodeStatus.Open)
     {
         return NodeRecords[nodeRecord.node.NodeIndex];
     }
     else
     {
         return null;
     }
 }
开发者ID:MiguelPires,项目名称:Path-Follower-Agent,代码行数:11,代码来源:NodeRecordArray.cs


示例17: 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
     int hashCode = nodeRecord.GetHashCode();
     if (NodeRecords.ContainsKey(hashCode))
     {
         return NodeRecords[hashCode];
     }
     return null;
 }
开发者ID:RicardoEPRodrigues,项目名称:IAJ-Labs,代码行数:12,代码来源:HashTableNodeList.cs


示例18: AddToOpen

        public void AddToOpen(NavigationGraphNode key, NodeRecord nodeRecord)
        {
            //a little help here
            //is very nice that the List<T> already implements a binary search method
            int index = this.Open.BinarySearch(nodeRecord);
            if (index < 0)
            {

                this.Open.Insert(~index, nodeRecord);
            }
            else
                this.Replace(this.Open[index], nodeRecord);
        }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:13,代码来源:LeftPriorityList.cs


示例19: pushNode

        private void pushNode(NodeRecord nodeRecord, NodeRecord parent, int edgeGraphIndex, float givenCost)
        {
            

            var nodeInOpen = NodeRecords.SearchInOpen(nodeRecord.node, nodeRecord);

            if(nodeRecord.status == NodeStatus.Unvisited || nodeRecord.fValue > givenCost) {
                
                nodeRecord.parent = parent;
                nodeRecord.edgeFromStart = edgeGraphIndex;
                nodeRecord.fValue = givenCost;

                if (nodeRecord.status == NodeStatus.Unvisited)
                {
                    this.NodeRecords.AddToOpen(nodeRecord.node, nodeRecord);
                }
                else if (nodeRecord.status == NodeStatus.Open)
                {
                    this.NodeRecords.Replace(nodeInOpen, nodeRecord);
                }
            }
        }
开发者ID:affonseca,项目名称:Goal-Bounding-on-NavMesh,代码行数:22,代码来源:DijkstraFloodfill.cs


示例20: InitializePathfindingSearch

        public void InitializePathfindingSearch(RectangleCharacter startPosition)
        {
            Point initp = new Point(WM, WM.Character.xPos, WM.Character.yPos);
            Point aux = new Point(WM, 9999, 9999);
            float dist = 99999999999;
            foreach (Point p in WM.Mesh)
            {
                float auxd = initp.DistanceTo(p);
                if (auxd <= dist)
                {
                    aux = p;
                    dist = auxd;
                }
            }
            Connection c = new Connection(WM, initp, aux);
            c.categorie = c.SLIDEONPLATFORM;
            initp.addConnection(c);
            NodeRecord nri = new NodeRecord();
            nri.node = initp;
            nri.gValue = 0;
            nri.hValue = 0;
            nri.fValue = 0;
            nri.Points = 0;
            var bestNode = nri;
            this.StartNode = initp;

            

            this.InProgress = true;
            this.TotalProcessedNodes = 0;
            this.MaxOpenNodes = 0;
            

            this.Open.Initialize();

            this.Open.AddToOpen(bestNode);
            this.Closed.Initialize();
        }
开发者ID:IAJ-g04,项目名称:Project4,代码行数:38,代码来源:AStartPathfinding.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NodeReference类代码示例发布时间:2022-05-24
下一篇:
C# NodeMigrationData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap