Exemplo n.º 1
0
    /*
     * private void OnCollisionEnter(Collision collision)
     * {
     *  if (collision.transform.CompareTag("Jeep"))
     *  {
     *      Debug.Log("Jeep");
     *      rbCurrent.AddForce(0, 0, -0.3f);
     *      collision.gameObject.GetComponent<Rigidbody>().AddForce(0, 0, 0.3f);
     *  }
     * }
     */
    // Update is called once per frame
    void FixedUpdate()
    {
        transform.rotation = Quaternion.Euler(0, 90, 0);
        rbCurrent.velocity = new Vector3(rbCurrent.velocity.x, 0, 0);

        if (6 > transform.position.x && transform.position.x > -6)
        {
            rbCurrent.velocity = new Vector3(13f, 0, 0);
        }

        if (col.Equals(Color.red) && haventStartedYet && transform.position.x > -30)
        {
            //Debug.Log("1111");
            startTime        = Time.time;
            haventStartedYet = false;
        }

        if (!haventStartedYet && haventEndedYet && transform.position.x > -4)
        {
            //Debug.Log("2222");
            endTime        = Time.time;
            haventEndedYet = false;

            myTime = endTime - startTime;
            trafficLightAI.getWaitingTime(myTime, 'X');

            /*
             * trafficLightAI.totalTimeX += myTime; ;
             * this.totalNumberOfCars = trafficLightAI.totalNumberOfCarsX;
             * Debug.Log(totalNumberOfCars);
             * meanXText.text = "Mean Waiting Time in Lane 1 = " + trafficLightAI.totalTimeX / totalNumberOfCars;
             */
        }

        if (!countedOnce && transform.position.x > 5)
        {
            trafficLightAI.getCountPassed('X');
            countedOnce = true;
        }
    }
Exemplo n.º 2
0
    /*
     * private void OnCollisionEnter(Collision collision)
     * {
     *  if (collision.transform.CompareTag("Jeep"))
     *  {
     *      Debug.Log("Jeep");
     *      rbCurrent.AddForce(0, 0, -0.3f);
     *      collision.gameObject.GetComponent<Rigidbody>().AddForce(0, 0, 0.3f);
     *  }
     * }
     */
    // Update is called once per frame
    void FixedUpdate()
    {
        transform.rotation = Quaternion.Euler(0, 0, 0);
        rbCurrent.velocity = new Vector3(0, 0, rbCurrent.velocity.z);

        if (6 > transform.position.z && transform.position.z > -6)
        {
            rbCurrent.velocity = new Vector3(0, 0, 13f);
        }

        if (col.Equals(Color.red) && haventStartedYet && transform.position.z > -30)
        {
            startTime        = Time.time;
            haventStartedYet = false;
        }
        if (!haventStartedYet && haventEndedYet && transform.position.z > -4)
        {
            endTime        = Time.time;
            haventEndedYet = false;

            myTime = endTime - startTime;
            trafficLightAI.getWaitingTime(myTime, 'Z');

            /*
             * trafficLightAI.totalTimeZ += myTime;
             * trafficLightAI.totalNumberOfCarsZ++;
             * Debug.Log(totalNumberOfCars);
             * meanZText.text = "Mean Waiting Time in Lane 2 = " + trafficLightAI.totalTimeZ / totalNumberOfCars;
             */
        }

        if (!countedOnce && transform.position.z > 5)
        {
            trafficLightAI.getCountPassed('Z');
            countedOnce = true;
        }
    }