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