void depart() { Unitilities.Tuples.Tuple <GameObject, bool> val = m_transportLine.getNextNode(m_currentNode, m_direction); m_targetNode = val.first; m_direction = val.second; m_state = TrainDefs.TrainState.Travelling; }
//Return the next node gameobject and the direction the next node is in. public Unitilities.Tuples.Tuple <GameObject, bool> getNextNode(GameObject currentNode, bool currentDirection) { Unitilities.Tuples.Tuple <GameObject, bool> rv = new Unitilities.Tuples.Tuple <GameObject, bool> (null, false); rv.second = currentDirection; int currentIndex = gameObjectToNodeIndex(currentNode); int newIndex = currentIndex; if (currentDirection == false) { if (currentIndex + 1 >= m_nodes.Count) { if (m_isLoop) { newIndex = 0; } else { newIndex = currentIndex - 1; rv.second = !currentDirection; } } else { newIndex = currentIndex + 1; } } else { if (currentIndex - 1 < 0) { if (m_isLoop) { newIndex = m_nodes.Count - 1; } else { newIndex = currentIndex + 1; rv.second = !currentDirection; } } else { newIndex = currentIndex - 1; } } rv.first = m_nodes [newIndex]; return(rv); }