private void CheckNodesChanged() { //Check if the nodes have been changed bool hasChangedNodeA = _lastNodeA == null && nodeA != null || _lastNodeA != null && _lastNodeA != nodeA; bool hasChangedNodeB = _lastNodeB == null && nodeB != null || _lastNodeB != null && _lastNodeB != nodeB; //Invoke OnNodesChanged List <PTGraphNode> changedNodes = new List <PTGraphNode>(); if (hasChangedNodeA) { changedNodes.Add(nodeA); } if (hasChangedNodeB) { changedNodes.Add(nodeB); } if (changedNodes.Count != 0) { OnNodesChanged(changedNodes); } //Update last nodes _lastNodeA = nodeA; _lastNodeB = nodeB; }
private void Awake() { datetimeConstructed = DateTime.Now; _lastNodeA = nodeA; _lastNodeB = nodeB; RegisterToNodes(); OnNodesChanged = (nodes) => RegisterToNodes(); }
public bool IsNodeA(PTGraphNode node) { return(nodeA != null && nodeA == node || nodeA == null && node == null); }
public bool ContainsNode(PTGraphNode node) { return(IsNodeA(node) || IsNodeB(node)); }
public bool IsNodeB(PTGraphNode node) { return(nodeB != null && nodeB == node || nodeB == null && node == null); }
/// <summary> /// Returns the shortest distance between nodeA and node B. /// </summary> /// <param name="nodeA"></param> /// <param name="nodeB"></param> /// <returns>Returns the distance if two nodes are connected. Returns -1 if they are not.</returns> public static int ShortestDistanceBetween(PTGraphNode nodeA, PTGraphNode nodeB) { throw new NotImplementedException(); }
/// <summary> /// Find the shortest path to a node from this node /// </summary> /// <param name="destination"></param> /// <returns>The list with right sequence</returns> public List <PTGraphEdge> ShortestDistanceTo(PTGraphNode destination) { throw new NotImplementedException(); }