Condividi tramite


GKGraph.FindPath(GKGraphNode, GKGraphNode) Metodo

Definizione

Restituisce una matrice di T:GamplayKit.GKGraphNode che rappresenta il percorso in ordine più basso. Se non esiste alcun percorso, restituisce una matrice vuota.

[Foundation.Export("findPathFromNode:toNode:")]
public virtual GameplayKit.GKGraphNode[] FindPath (GameplayKit.GKGraphNode startNode, GameplayKit.GKGraphNode endNode);
abstract member FindPath : GameplayKit.GKGraphNode * GameplayKit.GKGraphNode -> GameplayKit.GKGraphNode[]
override this.FindPath : GameplayKit.GKGraphNode * GameplayKit.GKGraphNode -> GameplayKit.GKGraphNode[]

Parametri

startNode
GKGraphNode
endNode
GKGraphNode

Restituisce

Attributi

Commenti

Di seguito viene illustrata la definizione del percorso in un grafico semplice:

var a = GKGraphNode2D.FromPoint (new Vector2 (0, 5));
var b = GKGraphNode2D.FromPoint (new Vector2 (3, 0));
var c = GKGraphNode2D.FromPoint (new Vector2 (2, 6));
var d = GKGraphNode2D.FromPoint (new Vector2 (4, 6));
var e = GKGraphNode2D.FromPoint (new Vector2 (2, 5));
var f = GKGraphNode2D.FromPoint (new Vector2 (2, 2));

a.AddConnections (new [] { b, c }, false);
b.AddConnections (new [] { e, f }, false);
c.AddConnections (new [] { d }, false);
d.AddConnections (new [] { e, f }, false);

var graph = GKGraph.FromNodes(new [] { a, b, c, d, e, f });

var a2e = graph.FindPath (a, e); // [ a, c, d, e ]
var a2f = graph.FindPath (a, f); // [ a, b, f ]

Si applica a