Пример #1
0
 /// <summary>
 /// Adds a transition from this node to the <paramref name="target"/>
 /// </summary>
 /// <param name="target">The node to connect to</param>
 public void AddTransition(Node target)
 {
     if (!hasTransition(target)) {
         var transition = new Transition(this, target);
         target.Transitions.Add(this, transition);
         Transitions.Add(target, transition);
     }
 }
Пример #2
0
 /// <summary>
 /// sees if the node has a connection a node <paramref name="target"/>
 /// </summary>
 /// <param name="target"></param>
 /// <returns>true if the node is connected to <paramref name="target"/></returns>
 private bool hasTransition(Node target)
 {
     return Transitions.Values.Any(transition => (transition.Nodes[0] == target) || (transition.Nodes[1] == target));
 }
Пример #3
0
 /// <summary>
 /// Finds the distance between 2 nodes
 /// </summary>
 /// <param name="a">First Node</param>
 /// <param name="b">Second Node</param>
 /// <returns>Distance between node params</returns>
 public static float distanceBetween(Node a, Node b)
 {
     return (a.Position - b.Position).magnitude;
 }