Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------------

        ///<summary>
        ///(Sphere Audio) Instiante a sound, play it and then destroy it
        ///<param name="aSound">The AudioData, with all setting already set, that need to be play</param>
        ///<param name="aPosition">The position where the sound will be instantiate</param>
        ///</summary>
        public void SoundEasy_Play(AudioData aSound, Vector3 aPosition)
        {
            if (!SFX_IsInit(true))
            {
                return;
            }
            if (aSound == null)
            {
                Debug.LogWarning(Debug_Warning("There's no sound to play"));
                return;
            }
            SFX_AudioSetup audio = Instantiate(new GameObject(), aPosition, Quaternion.identity).AddComponent <SFX_AudioSetup>();

            audio.SetAudioSource();
            audio.SetupAudio(aSound.GetClip(), aSound.GetVolume(), aSound.GetPitch(), aSound.GetSpatialBlend(), aSound.GetStereoPan());
            audio.PlayAudio(aSound.GetDelay());
        }
Ejemplo n.º 2
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);
        }