Exemplo n.º 1
0
    public void EngineUI_view1_onSpokeSoundClick()
    {
        if (m_current_spoke != -1)
        {
            double spoke_force = m_WheelModel.getSpokeForceN(m_current_spoke);
            if (spoke_force > 15.0)
            {
                float frequency = (float)(Math.Sqrt(spoke_force / m_WheelModel.getSpokeUnitMass()) / (2 * m_WheelModel.getSpokeTightenedLength(m_current_spoke)));

                m_AudioSource.clip  = m_spokes_AudioClips[UnityEngine.Random.Range(0, m_spokes_AudioClips.Length)];
                m_AudioSource.pitch = frequency / m_spokes_AudioClips_reference_frequency;
                m_AudioSource.Play();
            }
            else
            {
                m_AudioSource.Stop();
            }
        }
    }