Esempio n. 1
0
    private void Update()
    {
        float   deltaTime   = Time.deltaTime;
        Vector3 rhs         = base.transform.position - m_lastPos;
        float   magnitude   = rhs.magnitude;
        float   num         = magnitude / deltaTime;
        Vector3 eulerAngles = base.transform.rotation.eulerAngles;
        float   num2        = eulerAngles.y - m_lastRot;
        float   num3        = (!(0f > Vector3.Dot(rhs.normalized, base.transform.forward))) ? 1f : (-1f);

        UpdateSound(deltaTime, num);
        if (num2 != 0f)
        {
            float num4 = 0f;
            if (Mathf.Abs(num2) > 10f * deltaTime)
            {
                num4 = num3 * ((!(num2 > 0f)) ? (-1f) : 1f);
            }
            m_leftWheel.localRotation  = Quaternion.Lerp(m_leftWheel.localRotation, m_startRotLeft * Quaternion.Euler(0f, num4 * 35f, 0f), deltaTime * 4f);
            m_rightWheel.localRotation = Quaternion.Lerp(m_rightWheel.localRotation, m_startRotRight * Quaternion.Euler(0f, num4 * 35f, 0f), deltaTime * 4f);
            float num5 = (!(Mathf.Abs(num4) > 0.5f)) ? 0f : (Mathf.Abs(num4) * 0.05f);
            float num6 = Mathf.Max(num - 12f, 0f) * 0.25f;
            m_soundSqueel.volume = Mathf.Clamp(Mathf.Lerp(m_soundSqueel.volume, num6 * num5, deltaTime), 0f, 0.12f);
        }
        else
        {
            m_soundSqueel.volume = 0f;
        }
        if (Vector3.zero != rhs)
        {
            float x = num * num3;
            m_leftWheel.localRotation     *= Quaternion.Euler(x, 0f, 0f);
            m_rightWheel.localRotation    *= Quaternion.Euler(x, 0f, 0f);
            m_rearWheels[0].localRotation *= Quaternion.Euler(x, 0f, 0f);
            m_rearWheels[1].localRotation *= Quaternion.Euler(x, 0f, 0f);
            m_nextEngineStartSound         = Time.time + 3f;
        }
        m_lastPos = base.transform.position;
        Vector3 eulerAngles2 = base.transform.rotation.eulerAngles;

        m_lastRot       = eulerAngles2.y;
        m_light.enabled = (m_dayNight.GetDayLight() == 0f && m_health > 0f);
    }