示例#1
0
	public void Play ( AudioSource _audioSource, ESoundType _soundType, string _clipName, bool _force )
	{
		if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled )
		{	
			if ( _force )
			{
				_audioSource.clip = GetAudioClip ( _clipName );
				_audioSource.Play();
			}
			else
			{
				if ( !_audioSource.isPlaying )
				{
					_audioSource.clip = GetAudioClip ( _clipName );
					_audioSource.Play();
				}
			}
		}
		if ( _soundType == ESoundType.Music && m_musicEnabled )
		{
			if ( _force )
			{
				_audioSource.clip = GetAudioClip ( _clipName );
				_audioSource.Play();
			}
			else
			{
				if ( !_audioSource.isPlaying )
				{
					_audioSource.clip = GetAudioClip ( _clipName );
					_audioSource.Play();
				}
			}
		}
	}
        private OneShotSoundComponent PlaySound(AudioClip sound, ESoundType soundType, ESoundLocalizationType localizationType, Vector3 position, float minRange = 0f, float maxRange = 0f)
        {
            OneShotSoundComponent oneShotSound       = null;
            GameObject            instantiatedSource = Instantiate(m_AudioSourcePrefab);

            if (instantiatedSource.TryGetComponent(out AudioSource source))
            {
                if (instantiatedSource.TryGetComponent(out oneShotSound))
                {
                    instantiatedSource.transform.position = position;
                    source.clip         = sound;
                    source.spatialBlend = (localizationType == ESoundLocalizationType.Global) ? 0f : 1f;
                    source.minDistance  = (minRange == 0f && maxRange == 0f) ? /*GET DEFAULT VALUE FROM SETTINGS*/ 10f : minRange;
                    source.maxDistance  = (minRange == 0f && maxRange == 0f) ? /*GET DEFAULT VALUE FROM SETTINGS*/ 10f : maxRange;
                    oneShotSound.SetSoundType(soundType);
                }
                else
                {
                    DebugUtils.LogWarning(this, "AudioSourcePrefab has no OneShotSoundComponent, sound will not be played");
                    Destroy(instantiatedSource);
                }
            }
            else
            {
                DebugUtils.LogWarning(this, "AudioSourcePrefab has no AudioSource component, sound will not be played");
                Destroy(instantiatedSource);
            }
            return(oneShotSound);
        }
    public void SetPlayingSoundType(ESoundType soundType)
    {
        int nextPlayingSoundIndex = 0;

        _soundTypesIndexesDictionary.TryGetValue(soundType, out nextPlayingSoundIndex);
        _playingSoundIndex = nextPlayingSoundIndex;
    }
示例#4
0
	public void Play ( AudioSource _audioSource, ESoundType _soundType, bool _force )
	{
		if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled )
		{
			if ( _force )
			{
				_audioSource.Play();
			}
			else
			{
				if ( !_audioSource.isPlaying )
				{
					_audioSource.Play();
				}
			}
		}
		if ( _soundType == ESoundType.Music && m_musicEnabled )
		{
			if ( _force )
			{
				_audioSource.Play();
			}
			else
			{
				if ( !_audioSource.isPlaying )
				{
					_audioSource.Play();
				}
			}
		}
	}
示例#5
0
	public void Play ( AudioSource _audioSource, ESoundType _soundType )
	{
		if ( _soundType == ESoundType.SoundEffect && m_soundsEnabled )
		{			
			_audioSource.Play();
		}
		if ( _soundType == ESoundType.Music && m_musicEnabled )
		{			
			_audioSource.Play();					
		}
	}
示例#6
0
    public void PlaySound(ESoundType soundType)
    {
        var soundClip = _soundStore.Sounds.FirstOrDefault(s => s.soundType == soundType);

        if (soundClip.audioClips.Count > 0)
        {
            _audioSource.PlayOneShot(soundClip.audioClips[Random.Range(0, soundClip.audioClips.Count - 1)]);
        }
        else
        {
            Debug.LogError($"No sound found for {{soundType}}");
        }
    }
示例#7
0
    public void PlaySound(string Name, ESoundType SoundType)
    {
        AudioClip LoadedClip = CResourceMgr.LoadSound(Name, SoundType);

        if (SoundType == ESoundType.BGM)
        {
            audioSource.clip = LoadedClip;
            audioSource.Play();
        }
        else
        {
            audioSource.PlayOneShot(LoadedClip);
        }
    }
    private void HookPlaySound(int oldSoundTypeIndex, int newSoundTypeIndex)
    {
        ESoundType correspondingSoundType = ESoundType.None;

        foreach (ESoundType soundType in Enum.GetValues(typeof(ESoundType)))
        {
            if (_soundTypesIndexesDictionary[soundType] == newSoundTypeIndex)
            {
                correspondingSoundType = soundType;
                _playingSoundType      = correspondingSoundType;
                break;
            }
        }

        PlaySound(correspondingSoundType);
    }
    public void PlaySound(ESoundType sfx)
    {
        SoundSource.clip = SoundList[(int)sfx];

        // volume
        switch(sfx)
        {
            case ESoundType.SwipeDown:
            case ESoundType.SwipeUp:
            case ESoundType.SwipeSide:
                SoundSource.volume = 0.2f;
                break;
            default:
                SoundSource.volume = 1f;
                break;
        }

        SoundSource.Play();
    }
示例#10
0
        public HierarchySoundSfxVoice(FArchive Ar) : base(Ar)
        {
            Ar.Position    += 2;
            SoundConversion = Ar.Read <ESoundConversion>();
            Ar.Position    += 1;
            SoundSource     = Ar.Read <ESoundSource>();
            SoundId         = Ar.Read <uint>();
            SourceId        = Ar.Read <uint>();

            if (SoundSource == ESoundSource.Embedded)
            {
                WemOffset = Ar.Read <uint>();
                WemLength = Ar.Read <uint>();
            }

            SoundType = Ar.Read <ESoundType>();

            //TODO
        }
    public void PlaySound(ESoundType soundType)
    {
        SoundList soundList = _soundLists.Find((potentialSoundList) => potentialSoundList.SoundType == soundType);

        if (soundList == null)
        {
            return;
        }

        AudioClip clip = soundList.Sounds[UnityEngine.Random.Range(0, soundList.Sounds.Count)];

        if (clip != null)
        {
            AudioSource.clip = clip;
            AudioSource.Play();
            _timer = 0f;
            _currentAudioLength = clip.length;
        }
    }
示例#12
0
    public void PlaySound(ESoundType sfx)
    {
        SoundSource.clip = SoundList[(int)sfx];

        // volume
        switch (sfx)
        {
        case ESoundType.SwipeDown:
        case ESoundType.SwipeUp:
        case ESoundType.SwipeSide:
            SoundSource.volume = 0.2f;
            break;

        default:
            SoundSource.volume = 1f;
            break;
        }

        SoundSource.Play();
    }
示例#13
0
        /// <summary>
        /// Plays an <see cref="AudioClip"/> in 2D.
        /// </summary>
        /// <param name="clip">The <see cref="AudioClip"/> to play.</param>
        public void PlayGlobalSound(AudioClip clip, ESoundType soundType)
        {
            AudioSource audioSource = GetAvailableAudioSource();

            audioSource.gameObject.SetActive(true);
            audioSource.clip         = clip;
            audioSource.spatialBlend = 0.0f;
            audioSource.maxDistance  = 5000;

            switch (soundType)
            {
            case ESoundType.Music:
                audioSource.outputAudioMixerGroup = musicMixer;
                break;

            case ESoundType.Sfx:
                audioSource.outputAudioMixerGroup = sfxMixer;
                break;
            }

            audioSource.Play();
        }
示例#14
0
    public static AudioClip LoadSound(string name, ESoundType SoundType)
    {
        switch (SoundType)
        {
        case ESoundType.BGM:
            name = "Sound/BGM/" + name;
            break;

        case ESoundType.Item:
            name = "Sound/SFX/Item/" + name;
            break;

        case ESoundType.Motion:
            name = "Sound/SFX/Motion/" + name;
            break;

        case ESoundType.UI:
            name = "Sound/SFX/UI/" + name;
            break;
        }
        return(Resources.Load <AudioClip>(name));
    }
 private OneShotSoundComponent Play3DSound(AudioClip sound, ESoundType type, Vector3 position, float maxRange, float minRange)
 {
     return(PlaySound(sound, type, ESoundLocalizationType.Point, position, minRange, maxRange));
 }
 //PRIVATE
 private OneShotSoundComponent Play2DSound(AudioClip sound, ESoundType type)
 {
     return(PlaySound(sound, type, ESoundLocalizationType.Global, Vector3.zero));
 }
示例#17
0
        /// <summary>
        /// Plays an <see cref="AudioClip"/> in 3D.
        /// </summary>
        /// <param name="clip">The <see cref="AudioClip"/> to play.</param>
        /// <param name="position">The position to play the clip at.</param>
        /// <param name="radius">How far away the <see cref="AudioClip"/> can be heard.</param>
        public void PlaySoundAtPosition(AudioClip clip, Vector3 position, float radius, ESoundType soundType)
        {
            AudioSource audioSource = GetAvailableAudioSource();

            audioSource.gameObject.SetActive(true);
            audioSource.transform.position = position;
            audioSource.clip         = clip;
            audioSource.spatialBlend = 1.0f;
            audioSource.maxDistance  = radius;

            switch (soundType)
            {
            case ESoundType.Music:
                audioSource.outputAudioMixerGroup = musicMixer;
                break;

            case ESoundType.Sfx:
                audioSource.outputAudioMixerGroup = sfxMixer;
                break;
            }

            audioSource.Play();
        }
 //PUBLIC
 public void SetSoundType(ESoundType soundType)
 {
     m_SoundType = soundType;
 }
示例#19
0
 public void Play(ESoundType soundType)
 {
     audioSource.PlayOneShot(sounds.First(i => i.Type == soundType).Clip);
 }
示例#20
0
 public SoundPlayInfo(ESoundType eType)
 {
     Clear();
     eSoundType = eType;
 }