Exemplo n.º 1
0
    /// <summary>
    /// <para>Plays the clip. </para>
    /// <para>option: pass in properties (Volume, Loop, etc) for LgAudioSource. </para>
    /// <para>option: isSoundClipManaged (T: LgAudioManager will keep a reference to this sound clip
    /// and will not allow the same sound clip to be played again until the current clip is stopped or
    /// finished, F: same sound can be played more than once and once the sound is played there's no
    /// way to stop it until it finishes)</para>
    /// </summary>
    /// <param name="clipName">Sound clip name</param>
    /// <param name="variations">Number of sounds for the same clip</param>
    /// <param name="hashOverrides">Hash overrides.</param>
    public virtual void PlayClip(string clipName, int variations = 1, Hashtable option = null)
    {
        if (option == null)
        {
            option = new Hashtable();
        }

        if (clipName == "")
        {
            Debug.LogError("Something trying to play a sound with an empty sound id...");
            return;
        }

        DataSound sound = DataSounds.GetSoundData(clipName, variations);

        if (sound == null)
        {
            Debug.LogError("No such sound with id " + clipName);
            return;
        }

        bool isSoundClipManaged = false;                // Set the default to false

        if (option.ContainsKey("IsSoundClipManaged"))
        {
            isSoundClipManaged = (bool)option["IsSoundClipManaged"];
        }

        //if multip sound mode is on. just play the clip
        if (!isSoundClipManaged)
        {
            LgAudioSource audioSource = PlaySound(sound, option);
            audioSource.OnDestroyed += LgAudioSourceDestroyed;
        }
        //if multi sound mode is off. check the dicitonary for the same clip
        else
        {
            if (!spawnedAudioSources.ContainsKey(clipName))
            {
                LgAudioSource audioSource = PlaySound(sound, option);
                spawnedAudioSources.Add(clipName, audioSource);
                audioSource.OnDestroyed += LgAudioSourceDestroyed;
            }
        }
    }
Exemplo n.º 2
0
	/// <summary>
	/// Plays the clip.
	/// </summary>
	/// <param name="soundClip">Sound clip.</param>
	/// <param name="hashOverrides">Hash overrides.</param>
	public void PlayClip(string soundClip, Hashtable hashOverrides = null){
		if(hashOverrides == null)
			hashOverrides = new Hashtable();
		
		if(soundClip == ""){
			Debug.LogError("Something trying to play a sound with an empty sound id...");
			return;
		}
		
		DataSound sound = DataSounds.GetSoundData(soundClip);
		
		if(sound == null){
			Debug.LogError("No such sound with id " + soundClip);
			return;
		}
		
		PlaySound(sound, hashOverrides);	
	}