예제 #1
0
 void OnEnable()
 {
     creator = target as TransLineCreator;
     creator.SetLines(GameObject.FindGameObjectsWithTag("TransLine"));
     creator.SetStations(FindObjectsOfType <StationController>());
     creator.mainRouter = FindObjectOfType <RoutingController>();
 }
예제 #2
0
    public void CreateBusLines()
    {
        if (busInfo == null)
        {
            Debug.Log("no busInfo loaded.");
            return;
        }

        TransLineCreator creator = TransLineCreator.AttachToGameObject();

        creator.SetLines(GameObject.FindGameObjectsWithTag("TransLine"));
        creator.SetStations(FindObjectsOfType <StationController>());

        // Go through the flows (bus lines) in busInfo.
        foreach (var flow in busInfo.flows)
        {
            creator.ResetEditingInfo();
            creator.editLineName = flow.id;
            creator.lineCategory = LineCategory.Bus;
            foreach (var stop in flow.stops)
            {
                var go = GameObject.Find(stop.busStop);
                creator.AddStationToNewLine(go.GetComponentInParent <StationController>());
            }
            // LATER TODO: Calculate the traveling time in Sumo based on maxSpeed and length of the edges.
            creator.CreateNewLine();
        }

        DestroyImmediate(creator);
    }