Beispiel #1
0
    public SoundEffect GetSound()
    {
        float p = RangePercent;

        if (sounds.Length > 0)
        {
            SoundScale  sp = Sound(p);
            SoundEffect s  = sp.Sound();
            return(s);
        }
        if (soundProfiles.Length > 0)
        {
            SoundProfile sp = soundProfiles[Mathf.RoundToInt(Mathf.Lerp(0, soundProfiles.Length - 1, clipSelect.Evaluate(p)))];
            Debug.Log(sp.name);

            SoundEffect s = sp.GetSound();
            return(s);
        }

        return(null);
    }
Beispiel #2
0
    public void PlaySound()
    {
        if (cycle != null && cycle.RuntimeValue < cycle.MaxValue)
        {
            cycle.RuntimeValue++;
            return;
        }
        else if (cycle != null)
        {
            cycle.RuntimeValue = (int)cycle.MinValue;
        }
        switch (PitchVolume)
        {
        case VolumePitchMode.CounterCounter:
            audioSource.pitch  = clipPitch.Evaluate(Counter.Percent);
            audioSource.volume = clipVolume.Evaluate(Counter.Percent);
            break;

        case VolumePitchMode.CounterIdle:
            audioSource.pitch  = clipPitch.Evaluate(Counter.Percent);
            audioSource.volume = clipVolume.Evaluate(IdleTime.Percent);
            break;

        case VolumePitchMode.CounterSize:
            audioSource.pitch  = clipPitch.Evaluate(Counter.Percent);
            audioSource.volume = clipVolume.Evaluate(Size.Percent);
            break;

        case VolumePitchMode.IdleCounter:
            audioSource.pitch  = clipPitch.Evaluate(IdleTime.Percent);
            audioSource.volume = clipVolume.Evaluate(Counter.Percent);
            break;

        case VolumePitchMode.IdleIdle:
            audioSource.pitch  = clipPitch.Evaluate(IdleTime.Percent);
            audioSource.volume = clipVolume.Evaluate(IdleTime.Percent);
            break;

        case VolumePitchMode.IdleSize:
            audioSource.pitch  = clipPitch.Evaluate(IdleTime.Percent);
            audioSource.volume = clipVolume.Evaluate(Size.Percent);
            break;

        case VolumePitchMode.SizeCounter:
            audioSource.pitch  = clipPitch.Evaluate(Size.Percent);
            audioSource.volume = clipVolume.Evaluate(Counter.Percent);
            break;

        case VolumePitchMode.SizeIdle:
            audioSource.pitch  = clipPitch.Evaluate(Size.Percent);
            audioSource.volume = clipVolume.Evaluate(IdleTime.Percent);
            break;

        case VolumePitchMode.SizeSize:
            audioSource.pitch  = clipPitch.Evaluate(Size.Percent);
            audioSource.volume = clipVolume.Evaluate(Size.Percent);
            break;
        }
        SoundProfile.SoundEffect soundEffect = soundProfile.GetSound();
        //SoundProfile.SoundEffect soundEffect = soundProfile.GetSound(Size.Percent, Counter.Percent, IdleTime.Percent);
        if (soundEffect != null)
        {
            audioSource.PlayOneShot(soundEffect.clip);
            if (displayCaptions != null)
            {
                displayCaptions.AddCaption(soundProfile.CaptionColor, VolumePercent, soundProfile.before + soundEffect.caption + soundProfile.after);
            }
        }
        else
        {
            Debug.LogWarning("sound effect not found " + name);
        }
        //audioSource.PlayOneShot(soundProfile.Clip(Size.Percent, Counter.Percent, IdleTime.Percent));
    }