/// <summary>Checks if link with the target node is on or off. See TNELinksOnOffSwitch</summary> public bool LinkIsOnWith(TileNode withNode) { // first check if provided link is actually a neighbour of this one if (!IsDirectNeighbour(withNode)) { return(false); } int state = -1; // check if the link with the target is on or off if (linkOnOffSwitch != null) { // check if link is on with neighbour state = linkOnOffSwitch.LinkIsOn(withNode); } // not found? check if the neighbour is on carrying the link info if (state == -1) { if (withNode.linkOnOffSwitch != null) { // check if link is on from neighbour's side state = withNode.linkOnOffSwitch.LinkIsOn(this); } } // default is true, only return false if specifically told that link is off return(state == 0?false:true); }
/// <summary> /// Checks if link with the target node is on or off. See TNELinksOnOffSwitch /// </summary> public bool LinkIsOnWith(TileNode withNode) { // first check if provided link is actually a neighbour of this one if (!IsDirectNeighbour(withNode)) { return(false); } int state = -1; // linkOnOffSwitch might not be inited this fcuntion is called from editor if (linkOnOffSwitch == null) { linkOnOffSwitch = gameObject.GetComponent <TNELinksOnOffSwitch>(); } // check if the link with the target is on or off if (linkOnOffSwitch != null) { // check if link is on with neighbour state = linkOnOffSwitch.LinkIsOn(withNode); } // not found? check if the neighbour is on carrying the link info if (state == -1) { if (withNode.linkOnOffSwitch != null) { // check if link is on from neighbour's side state = withNode.linkOnOffSwitch.LinkIsOn(this); } } // default is true, only return false if specifically told that link is off return(state == 0?false:true); }
public bool LinkIsOnWith(TileNode withNode) { if (!IsDirectNeighbour(withNode)) { return(false); } int state = -1; if (linkOnOffSwitch != null) { state = linkOnOffSwitch.LinkIsOn(withNode); } if (state == -1) { if (withNode.linkOnOffSwitch != null) { state = withNode.linkOnOffSwitch.LinkIsOn(this); } } return(state == 0?false:true); }
static void RenderTileNodeGizmo(TileNode node, GizmoType gizmoType) { if (node.mapnav == null) { return; } Vector3 position = node.transform.position; Vector3 gizmoSize = TileNode.GizmoSize * (node.mapnav.tileSpacing / TileNode.GizmoSizeDiv); // draw cube(s) for node if (node.mapnav.gizmoDrawNodes || ((gizmoType & GizmoType.Selected) != 0)) { if ((gizmoType & GizmoType.Selected) != 0) { Gizmos.color = Color.red; Gizmos.DrawCube(position, gizmoSize); } else if (node.mapnav.gizmoColorCoding) { bool drawn = false; Vector3 offs = Vector3.zero; for (int i = 0; i < TileNode.GizmoColourCoding.Length; i++) { int t = (int)Mathf.Pow(2, i); if (((int)node.tileTypeMask & t) == t) { Gizmos.color = TileNode.GizmoColourCoding[i]; Gizmos.DrawCube(position + offs, gizmoSize); offs.y += gizmoSize.y; drawn = true; } } if (!drawn) { Gizmos.color = Color.black; Gizmos.DrawCube(position, gizmoSize); } } else { Gizmos.color = Color.black; Gizmos.DrawCube(position, gizmoSize); } } // draw the node links if (node.nodeLinks != null && (node.mapnav.gizmoDrawLinks || (gizmoType & GizmoType.Selected) != 0)) { TNELinksOnOffSwitch linkSwitch = node.gameObject.GetComponent <TNELinksOnOffSwitch>(); foreach (TileNode n in node.nodeLinks) { if (n != null) { Gizmos.color = Color.blue; if (linkSwitch != null) { // check if lik is on with neighbour if (linkSwitch.LinkIsOn(n) == 0) { Gizmos.color = Color.red; } } TNELinksOnOffSwitch nls = n.gameObject.GetComponent <TNELinksOnOffSwitch>(); if (nls != null) { // check if neighbour's link with me is on if (nls.LinkIsOn(node) == 0) { Gizmos.color = Color.red; } } Gizmos.DrawLine(position, n.transform.position); } } // look for forced links TNEForcedLink fl = node.gameObject.GetComponent <TNEForcedLink>(); if (fl != null) { foreach (TileNode link in fl.links) { if (link == null) { continue; } Gizmos.DrawLine(position, link.transform.position); } } } }