protected override void Start() { base.Start(); path = Scene.Main.World.Asteroid.HighwaySystem .PlanRoadtrip(transform.position, Target.Position); }
private void button4_Click(object sender, EventArgs e) { if (demoGraph.nodes.Count < 2) { graphOutput.Text = "Please add at least 2 nodes."; return; } Graph.Node start = null; Graph.Node end = null; foreach (Graph.Node n in demoGraph.nodes) { if (n.name == graphStartNode.Text) { start = n; } if (n.name == graphEndNode.Text) { end = n; } } if (start == null || end == null) { graphOutput.Text = "Please enter valid start and end nodes."; return; } Graph.Path answer = Graph.Graph.dijkstra(demoGraph, start, end); if (answer.path.Count <= 1) { graphOutput.Text = "No valid path found."; return; } string output = "Cost: " + answer.cost.ToString() + ". Path: "; foreach (Graph.Node n in answer.path) { output += n.name + ", "; } output = output.Remove(output.Length - 2); graphOutput.Text = output; }