private eAudioM_GroundType GetGroundType(eAudioM_FootSoundDir aDir)
    {
        Vector3 footPos = Vector3.zero;

        switch (aDir)
        {
        case eAudioM_FootSoundDir.Left:
        {
            if (m_GroundCheck_LeftFootPoint != null)
            {
                footPos = m_GroundCheck_LeftFootPoint.position;
            }
            else
            {
                Debug.Log("There's no Left foot point to check ground.");
            }

            break;
        }

        case eAudioM_FootSoundDir.Right:
        {
            if (m_GroundCheck_RightFootPoint != null)
            {
                footPos = m_GroundCheck_RightFootPoint.position;
            }
            else
            {
                Debug.Log("There's no Right foot point to check ground.");
            }
            break;
        }
        }
        if (Physics.Raycast(footPos, Vector3.down, out m_Hit, m_DistanceFromGround, m_GroundLayer))
        {
            GroundSelector ground = m_Hit.transform.GetComponent <GroundSelector>();
            if (ground != null)
            {
                return(ground.GetGroundType());
            }
        }

        return(eAudioM_GroundType.Grass);
    }
Exemple #2
0
        ///<summary>Return the correct stereoPan with the ask footSound direction</summary>
        private float FootSound_GetStereoPan(eAudioM_FootSoundDir aDir)
        {
            float stereoPan = 0.0f;

            switch (aDir)
            {
            case eAudioM_FootSoundDir.Left:
            {
                stereoPan = -0.1f;
                break;
            }

            case eAudioM_FootSoundDir.Right:
            {
                stereoPan = 0.1f;
                break;
            }
            }

            return(stereoPan);
        }
Exemple #3
0
        //--------------------------------------------------------------------------------------------

        ///<summary>
        ///(Sphere Audio) Instiante a foot sound depend on which ground you are on, play it and then destroy it
        ///<param name="aPosition">The position where the sound will be instantiate</param>
        ///<param name="aGroundType">The type of ground you are moving on</param>
        ///<param name="aMovementType">The type of movement you are doing</param>
        ///<param name="aFootDir">The foot that will touch the ground and make sound</param>
        ///</summary>
        public void FootSound_Play(Vector3 aPosition, eAudioM_GroundType aGroundType, eAudioM_FootSoundType aMovementType, eAudioM_FootSoundDir aFootDir)
        {
            if (!FootSound_IsInit(true))
            {
                return;
            }

            AudioClip clip = null;

            switch (m_FootAudioSelector)
            {
            case eAudioM_AudioSelector.AudioClip:
            {
                clip = m_FootSoundsData.GetFootSound(aGroundType, aMovementType);
                break;
            }

            case eAudioM_AudioSelector.AudioData:
            {
                AudioData data = m_FootSoundsData.GetFootSoundData(aGroundType, aMovementType);
                if (data == null)
                {
                    Debug.LogWarning(Debug_Warning("There's no AudioData available for the ground '" + aGroundType + "' and the movement type '" + aMovementType + "'"));
                    return;
                }
                data.StereoPan = FootSound_GetStereoPan(aFootDir);
                SoundEasy_Play(data, aPosition);
                return;
            }
            }

            if (clip == null)
            {
                Debug.LogWarning(Debug_Warning("There's no sound to play"));
                return;
            }

            GameObject obj = new GameObject();

            obj.transform.position = aPosition;
            SFX_AudioSetup audio = obj.AddComponent <SFX_AudioSetup>();

            audio.SetupAudio(clip, m_FootSoundsData.GetFootSoundVolume(aGroundType, aMovementType), 1.0f, 1.0f, FootSound_GetStereoPan(aFootDir));
            audio.PlayAudio(0);
        }