Beispiel #1
0
 /// <summary>
 /// Pauses the current music / sound for the sent mixer.
 /// </summary>
 /// <param name="player"></param>
 public void PauseAudio(MixerPlayer player)
 {
     foreach (Mixer m in mixers)
     {
         if (m.player == player)
         {
             m.Pause();
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Resumes the current music / sound for the sent mixer.
 /// </summary>
 /// <param name="player"></param>
 public void ResumeAudio(MixerPlayer player)
 {
     foreach (Mixer m in mixers)
     {
         if (m.player == player)
         {
             m.Resume();
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Unmutes the sent mixer.
 /// </summary>
 /// <param name="player"></param>
 public void UnMute(MixerPlayer player)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             m.UnMute();
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Will cancel or close any existing sound based on the shortest time left in one of the mixers. Will also adjust the mixer to the desired pitch.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 /// <param name="pitch"></param>
 public void PlaySoundOverride(MixerPlayer player, AudioClip sound, float pitch)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             m.OverridePlaySound(sound, pitch);
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// Plays a Combined sound into one of the mixer groups, will try to find a group that is using the closest pitch.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 /// <param name="pitch"></param>
 public void PlaySoundCombined(MixerPlayer player, AudioClip sound, float pitch)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             m.PlayCombinedSound(sound, pitch);
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// Plays the sound in an available mixer with the desired pitch.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 /// <param name="pitch"></param>
 public void PlaySound(MixerPlayer player, AudioClip sound, float pitch, bool enableLooping)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             m.PlaySound(sound, pitch, enableLooping);
         }
     }
 }
Beispiel #7
0
 /// <summary>
 /// Adds an outside audio source to the desired player to provide control over that source.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="source"></param>
 public void AddAudioSourceToMixer(MixerPlayer player, AudioSource source)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             m.AddSource(source);
             return;
         }
     }
 }
Beispiel #8
0
 /// <summary>
 /// Returns the mixer that is associate with that player.
 /// </summary>
 /// <param name="player"></param>
 /// <returns></returns>
 public Mixer GetMixer(MixerPlayer player)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             return(m);
         }
     }
     return(null);
 }
Beispiel #9
0
 /// <summary>
 /// Stops all other mixer channels sounds over the sent time and plays the AudioClip at the designated pitch and allows looping.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 /// <param name="pitch"></param>
 /// <param name="seconds"></param>
 public void TransitionSound(MixerPlayer player, AudioClip sound, float pitch, float seconds, bool enableLooping)
 {
     foreach (Mixer m in mixers)
     {
         if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
         {
             AudioSource[] sources = m.MuteAllOverlayPlaySound(sound, pitch, enableLooping);
             foreach (AudioSource source in sources)
             {
                 StartCoroutine(MuteSourceOverTime(source, seconds));
             }
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// Adjusts the volume of the sent mixer.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="volumeLevel"></param>
        public void AdjustVolume(MixerPlayer player, float volumeLevel)
        {
            if (EnumFlags <MixerPlayer> .HasAllFlags(player, MixerPlayer.Dialog, MixerPlayer.Explosions, MixerPlayer.Instantiations, MixerPlayer.Interactions, MixerPlayer.Movement, MixerPlayer.Music))
            {
                AdjustMasterVolume(volumeLevel);
                return;
            }

            foreach (Mixer m in mixers)
            {
                if (EnumFlags <MixerPlayer> .HasFlag(m.player, player))
                {
                    m.AdjustVolume(volumeLevel);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Plays a sound a designated location by creating a new audioSource, can be automatically added to a player for additional control.
        /// </summary>
        /// <param name="sound"></param>
        /// <param name="location"></param>
        public void PlaySoundAtLocation(MixerPlayer player, AudioClip sound, Vector3 location)
        {
            GameObject obj = new GameObject();

            obj = Instantiate(obj, location, Quaternion.identity);
            AudioSource source = obj.AddComponent <AudioSource>();

            source.clip = sound;
            Mixer m = GetMixer(player);

            if (m != null)
            {
                AudioMixerGroup group = m.GetMixerGroup();
                if (group != null)
                {
                    source.outputAudioMixerGroup = group;
                }
            }
            source.Play();
        }
Beispiel #12
0
 /// <summary>
 /// Stops all other mixer channel's sounds over the sent time and plays the AudioClip at the designated pitch.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 /// <param name="pitch"></param>
 /// <param name="seconds"></param>
 public void TransitionSound(MixerPlayer player, AudioClip sound, float pitch, float seconds)
 {
     TransitionSound(player, sound, pitch, seconds, false);
 }
Beispiel #13
0
 /// <summary>
 /// Plays the sound in an available mixer.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 public void PlaySound(MixerPlayer player, AudioClip sound, float pitch)
 {
     PlaySound(player, sound, pitch, false);
 }
Beispiel #14
0
 /// <summary>
 /// Plays the sound in an available mixer.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="sound"></param>
 public void PlaySound(MixerPlayer player, AudioClip sound)
 {
     PlaySound(player, sound, 1, false);
 }
Beispiel #15
0
 public Mixer(MixerPlayer player, AudioMixer mixer, string groupPrefix)
 {
     this.player      = player;
     this.mixer       = mixer;
     this.groupPrefix = groupPrefix;
 }