当前位置: 首页>>代码示例>>C#>>正文


C# Heap.EnleverPremier方法代码示例

本文整理汇总了C#中Heap.EnleverPremier方法的典型用法代码示例。如果您正苦于以下问题:C# Heap.EnleverPremier方法的具体用法?C# Heap.EnleverPremier怎么用?C# Heap.EnleverPremier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Heap的用法示例。


在下文中一共展示了Heap.EnleverPremier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrouverPath2

        IEnumerator TrouverPath2(Vector3 positionDépart, Vector3 positionCible)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            Vector3[] wayPoints = new Vector3[0];
            bool pathSuccess = false;
            Node nodeDépart = Grille.NodePositionMonde(positionDépart);
            Node nodeCible = Grille.NodePositionMonde(positionCible);

            if (nodeCible.EstSurfacePourMarcher) //nodeDépart.EstSurfacePourMarcher && nodeCible.EstSurfacePourMarcher)
            {
                //List<Node> openSet = new List<Node>(Grille.TailleMax);
                Heap<Node> openSet = new Heap<Node>(Grille.TailleMax);
                HashSet<Node> closedSet = new HashSet<Node>();
                openSet.Add(nodeDépart);

                while (openSet.Count > 0)
                {
                    //Node nodeActuel = openSet[0];
                    //for (int i = 1; i < openSet.Count; ++i)
                    //{
                    //	if (openSet [i].FCost < nodeActuel.FCost || openSet [i].FCost == nodeActuel.FCost && openSet [i].HCost < nodeActuel.HCost)
                    //	{
                    //		nodeActuel = openSet [i];
                    //	}
                    //}
                    //openSet.Remove (nodeActuel);
                    Node nodeActuel = openSet.EnleverPremier();
                    closedSet.Add(nodeActuel);

                    if (nodeActuel == nodeCible)
                    {
                        stopwatch.Stop();
                        Debug.Print("Path trouvé: " + stopwatch.ElapsedMilliseconds + " ms");
                        //RetracerPath(nodeDépart, nodeCible);
                        //return;
                        pathSuccess = true;
                        break;
                    }

                    foreach (Node voisin in Grille.GetVoisins(nodeActuel))
                    {
                        if (!voisin.EstSurfacePourMarcher || closedSet.Contains(voisin))
                        {
                            continue;
                        }
                        int CoutNouveauMouvementVoisin = nodeActuel.GCost + GetDistance(nodeActuel, voisin);
                        if (CoutNouveauMouvementVoisin < voisin.GCost || !openSet.Contains(voisin))
                        {
                            voisin.GCost = CoutNouveauMouvementVoisin;
                            voisin.HCost = GetDistance(voisin, nodeCible);
                            voisin.Parent = nodeActuel;
                            if (!openSet.Contains(voisin))
                            {
                                openSet.Add(voisin);
                            }
                            else
                            {
                                openSet.UpdateObjet(voisin);
                            }
                        }
                    }
                }
            }
            yield return null;                                                  // // // non
            if (pathSuccess)                                                    // // // non
            {                                                                   // // // non
                wayPoints = RetracerPath2(nodeDépart, nodeCible);                // // // non
            }                                                                   // // // non
            RequêtePathManager.FinishingProcessingPath(wayPoints, pathSuccess); // // // non
        }
开发者ID:karmoka,项目名称:DerniereFoisGuys,代码行数:71,代码来源:Pathfinding.cs


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