void arriveAtNode() { Debug.Log("We have arrived! Do some cleanup maybe"); m_currentNode = m_targetNode; m_targetNode = null; m_state = TrainDefs.TrainState.ReadyToDepart; }
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; }
//basic travel to next node. stop at all nodes. //TODO this will be upgraded to travelling 'routes' void travel() { transform.LookAt(m_targetNode.transform.position); Vector3 dir = m_targetNode.transform.position - transform.position; if (dir.magnitude < m_speed) { transform.position = m_targetNode.transform.position; //If at end of the line, arrive m_state = TrainDefs.TrainState.Arriving; } else { dir.Normalize(); dir *= m_speed; transform.position += dir; } }
// Use this for initialization void Start() { m_state = TrainDefs.TrainState.ReadyToDepart; }