void FindAllLightsRecursive(TrafficSystemIntersection a_trafficSystemIntersection, GameObject a_obj)
    {
        if (a_obj)
        {
            if (a_obj.GetComponent <TrafficSystemTrafficLight>())
            {
                TrafficSystemTrafficLight light = a_obj.GetComponent <TrafficSystemTrafficLight>();
                a_trafficSystemIntersection.m_lights.Add(light);
            }

            for (int cIndex = 0; cIndex < a_obj.transform.childCount; cIndex++)
            {
                Transform child = a_obj.transform.GetChild(cIndex);
                if (child.gameObject)
                {
                    FindAllLightsRecursive(a_trafficSystemIntersection, child.gameObject);
                }
            }
        }
    }
    public bool m_turnLeftAnytime                   = false;                         // if this is enabled, whenever a vehicle gets to this traffic light it will turn left straight away. It doesn't wait for a green arrow. The default should be false but there are a few special cases like the ends of T-Intersections that need it true!
//	public  bool               m_enableTurnChecks                 = false;
//	public  float              m_timeToWaitBetweenCheckes         = 1.0f;        // in seconds, the time we check to see if we can move again.
//	public  float              m_checkRadius                      = 5.0f;        // the size of the spherecast for checking vehicle detection.
//	public  Transform          m_checkPos;                                       // the position of the spherecast for checking vehicle detection.
//	private bool               m_checkStarted                     = false;

//	public  List<TrafficSystemVehicle> m_vehiclesStoppedAtLight = new List<TrafficSystemVehicle>();

    void Awake()
    {
        if (!m_intersection)
        {
            GameObject obj = TrafficSystemGameUtils.FindParentItem(gameObject, TrafficSystemGameUtils.GameObjectItem.TRAFFIC_SYSTEM_INTERSECTION);
            if (obj && obj.GetComponent <TrafficSystemIntersection>())
            {
                m_intersection = obj.GetComponent <TrafficSystemIntersection>();
            }
        }

        if (m_lightRedArrow)
        {
            m_lightRedArrow.gameObject.SetActive(true);
        }
        if (m_lightYellowArrow)
        {
            m_lightYellowArrow.gameObject.SetActive(false);
        }
        if (m_lightGreenArrow)
        {
            m_lightGreenArrow.gameObject.SetActive(false);
        }
    }
    void FindAllLightsRecursive(TrafficSystemIntersection a_trafficSystemIntersection, GameObject a_obj)
    {
        if(a_obj)
        {
            if(a_obj.GetComponent<TrafficSystemTrafficLight>())
            {
                TrafficSystemTrafficLight light = a_obj.GetComponent<TrafficSystemTrafficLight>();
                a_trafficSystemIntersection.m_lights.Add(light);
            }

            for(int cIndex = 0; cIndex < a_obj.transform.childCount; cIndex++)
            {
                Transform child = a_obj.transform.GetChild(cIndex);
                if(child.gameObject)
                    FindAllLightsRecursive(a_trafficSystemIntersection, child.gameObject);
            }
        }
    }
示例#4
0
    void Awake()
    {
        TrafficSystemIntersection = (TrafficSystemIntersection)target;

//		Debug.Log (TrafficSystemPiece.gameObject.name + ": " + TrafficSystemPiece.m_renderer.bounds.extents);
    }
    void Awake()
    {
        TrafficSystemIntersection = (TrafficSystemIntersection)target;

        //		Debug.Log (TrafficSystemPiece.gameObject.name + ": " + TrafficSystemPiece.m_renderer.bounds.extents);
    }
    //    public  bool               m_enableTurnChecks                 = false;
    //    public  float              m_timeToWaitBetweenCheckes         = 1.0f;        // in seconds, the time we check to see if we can move again.
    //    public  float              m_checkRadius                      = 5.0f;        // the size of the spherecast for checking vehicle detection.
    //    public  Transform          m_checkPos;                                       // the position of the spherecast for checking vehicle detection.
    //    private bool               m_checkStarted                     = false;
    //    public  List<TrafficSystemVehicle> m_vehiclesStoppedAtLight = new List<TrafficSystemVehicle>();
    void Awake()
    {
        if(!m_intersection)
        {
            GameObject obj = TrafficSystemGameUtils.FindParentItem( gameObject, TrafficSystemGameUtils.GameObjectItem.TRAFFIC_SYSTEM_INTERSECTION );
            if(obj && obj.GetComponent<TrafficSystemIntersection>())
                m_intersection = obj.GetComponent<TrafficSystemIntersection>();
        }

        if(m_lightRedArrow)
            m_lightRedArrow.gameObject   .SetActive(true);
        if(m_lightYellowArrow)
            m_lightYellowArrow.gameObject.SetActive(false);
        if(m_lightGreenArrow)
            m_lightGreenArrow.gameObject .SetActive(false);
    }