Пример #1
0
 /// <summary>
 /// Set the volume of the track passed as Param.
 /// </summary>
 static public void Volume(float volume, track trackCompare)
 {
     Sound[] snds = GetSounds(trackCompare);
     for (int i = 0; i < snds.Length; i++)
     {
         if (volume >= snds[i].maxVolume)
         {
             snds[i].volume           = snds[i].maxVolume;
             snds[i].lastVolumeSetted = snds[i].maxVolume;
         }
         else
         {
             snds[i].volume           = volume;
             snds[i].lastVolumeSetted = volume;
         }
     }
     for (int i = 0; i < _AllPlaying.Count; i++)
     {
         if (string.Equals(_AllPlaying[i].track.ToString(), trackCompare.ToString()) || trackCompare == track.All)
         {
             if (_AllPlaying[i].track == soundTrack.BackgroundSound && !_bkgMuted ||
                 _AllPlaying[i].track == soundTrack.EffectSound && !_efxMuted ||
                 _AllPlaying[i].track == soundTrack.VoiceSound && !_voiceMuted || !_allMuted)
             {
                 if (volume <= 1.0f)
                 {
                     if (volume > _AllPlaying[i].maxVolume)
                     {
                         _AllPlaying[i].currentSource.volume = _AllPlaying[i].maxVolume;
                         _AllPlaying[i].lastVolumeSetted     = _AllPlaying[i].maxVolume;
                     }
                     else
                     {
                         _AllPlaying[i].currentSource.volume = volume;
                         _AllPlaying[i].lastVolumeSetted     = volume;
                     }
                     if (volume == 0.0f)
                     {
                         _AllPlaying[i].isMuted     = true;
                         _AllPlaying[i].pauseEffect = true;
                     }
                     else
                     {
                         _AllPlaying[i].isMuted     = false;
                         _AllPlaying[i].pauseEffect = false;
                     }
                 }
                 else
                 {
                     _AllPlaying[i].isMuted = false;
                     _AllPlaying[i].currentSource.volume = _AllPlaying[i].lastVolumeSetted;
                 }
             }
         }
     }
 }
Пример #2
0
 static private void InternalVolume(float volume, track trackCompare)
 {
     volume = Mathf.Clamp01(volume);
     _AllPlaying.ForEach(x =>
     {
         if (string.Equals(x.track.ToString(), trackCompare.ToString()) || trackCompare == track.All)
         {
             x.currentSource.volume = volume;
         }
     });
 }
Пример #3
0
    static private Sound[] GetSounds(track trackCompare)
    {
        Sound[]      toReturn;
        List <Sound> hold = new List <Sound>();

        switch (trackCompare)
        {
        case track.BackgroundSound:
        case track.EffectSound:
        case track.VoiceSound:
            for (int i = 0; i < _AllSounds.Length; i++)
            {
                if (string.Equals(_AllSounds[i].track.ToString(), trackCompare.ToString()))
                {
                    hold.Add(_AllSounds[i]);
                }
            }
            break;

        case track.All:
            for (int i = 0; i < _AllSounds.Length; i++)
            {
                hold.Add(_AllSounds[i]);
            }
            break;
        }
        toReturn = new Sound[hold.Count];
        for (int i = 0; i < hold.Count; i++)
        {
            toReturn[i] = hold[i];
        }

        if (toReturn == null || toReturn.Length == 0)
        {
            Debug.LogWarning("There's no: " + trackCompare.ToString() + " Track set. Check the typo");
        }

        return(toReturn);
    }
Пример #4
0
    /// <summary>
    /// Return an Sound Array of the playing name with the track passed as Param.
    /// </summary>
    static public Sound[] GetSoundPlaying(track trackCompare)
    {
        List <Sound> hold = new List <Sound>();

        for (int i = 0; i < _AllPlaying.Count; i++)
        {
            if (trackCompare == track.All || string.Equals(_AllPlaying[i].track.ToString(), trackCompare.ToString()))
            {
                hold.Add(_AllSounds[i]);
            }
        }

        if (hold.Count == 0)
        {
            Debug.LogWarning("There's no: " + trackCompare.ToString() + " Track set. Check the typo");
        }

        return(hold.ToArray());
    }
Пример #5
0
    private static Sound[] GetSounds(track trackCompare)
    {
        Sound[] toReturn;
        List<Sound> hold = new List<Sound>();
        switch(trackCompare){
        case track.BackgroundSound:
        case track.EffectSound:
        case track.VoiceSound:
            for(int i = 0; i < _AllSounds.Length;i++){
                if(string.Equals(_AllSounds[i].track.ToString(), trackCompare.ToString())){
                    hold.Add(_AllSounds[i]);
                }
            }
            break;
        case track.All:
            for(int i = 0; i < _AllSounds.Length;i++){
                hold.Add(_AllSounds[i]);
            }
            break;
        }
        toReturn = new Sound[hold.Count];
        for(int i = 0; i<hold.Count;i++){
            toReturn[i] = hold[i];
        }

        if(toReturn == null || toReturn.Length == 0)
            Debug.LogWarning("There's no: "+trackCompare.ToString()+" Track set. Check the typo");

        return toReturn;
    }
Пример #6
0
    /// <summary>
    /// Set the volume of the track passed as Param.
    /// </summary>
    public static void Volume(float volume, track trackCompare)
    {
        Sound[] snds = GetSounds(trackCompare);
        for(int i = 0; i<snds.Length;i++){
            if(volume <= 1.0f){
                snds[i].volume = volume;
                if(volume > 0.0f)
                    snds[i].lastVolumeSetted = volume;
            }
        }
        for(int i=0;i<_AllPlaying.Count;i++){
            if(string.Equals(_AllPlaying[i].track.ToString(), trackCompare.ToString()) || trackCompare == track.All)
            {
                if(_AllPlaying[i].track == soundTrack.BackgroundSound && !bkgMuted ||
                    _AllPlaying[i].track == soundTrack.EffectSound && !efxMuted ||
                    _AllPlaying[i].track == soundTrack.VoiceSound && !voiceMuted){

                    if(volume <= 1.0f){
                        _AllPlaying[i].currentSource.volume = volume;
                        if(volume == 0.0f) _AllPlaying[i].isMuted = true;
                        else _AllPlaying[i].isMuted = false;
                        if(volume > 0.0f)
                            _AllPlaying[i].lastVolumeSetted = volume;
                    }else{
                        _AllPlaying[i].isMuted = false;
                        _AllPlaying[i].currentSource.volume = _AllPlaying[i].lastVolumeSetted;
                    }
                }
            }
        }
    }