Пример #1
0
    private IEnumerator ManageLoop(AudioSourceAnimator animator, LoopGroup group, EffectFader fader)
    {
        var FadeControl = new VolumeControl(0.0f);

        animator.AddControl(FadeControl);
        while (true)
        {
            fader.Update(Time.deltaTime);
            FadeControl.Volume = fader.Value;
            yield return(null);
        }
    }
Пример #2
0
    public void PlayClip(LoopGroup group, EffectFader fader)
    {
        var source = Pool.Grab();

        source.clip   = group.LoopedAudio;
        source.pitch  = group.PitchRange.x;
        source.volume = group.VolumeRange.x;
        source.loop   = true;

        var animator = new AudioSourceAnimator(source, TabFade, MasterVolume, SfxVolume);

        Animators.Add(animator);

        source.Play();
        StartCoroutine(ManageLoop(animator, group, fader));
    }
Пример #3
0
 public static void Play(LoopGroup group, EffectFader fader)
 {
     instance.PlayClip(group, fader);
 }
Пример #4
0
        private IEnumerator RunningRoutine()
        {
            while (true)
            {
                while (!breakoutFlag)
                {
                    yield return(null);
                }
                breakoutFlag = false;

                if (string.IsNullOrEmpty(currentText))
                {
                    continue;
                }

                var interpolator = new LinearInterpolator(42.0f);
                var fader        = new EffectFader(interpolator)
                {
                    TargetValue = 1.0f
                };

                AudioManager.Play(currentStyle.Audio.talkingLoop, fader);
                shakeElapsed = 0.0f;

                for (int i = 0; i < currentText.Length; i++)
                {
                    TextElement.text = $"{currentText.Substring(0, i + 1)}<color=\"#000\">{currentText.Substring(i + 1)}</color>";

                    yield return(new WaitForSeconds(currentStyle.Animation.DelayPerTick));

                    if (breakoutFlag)
                    {
                        break;
                    }

                    foreach (var exception in currentStyle.Animation.Exceptions)
                    {
                        if (exception.Character == currentText[i])
                        {
                            fader.TargetValue = 0.0f;
                            yield return(new WaitForSeconds(exception.PostDelay));

                            fader.TargetValue = 1.0f;

                            if (breakoutFlag)
                            {
                                break;
                            }
                        }
                    }

                    if (breakoutFlag)
                    {
                        break;
                    }

                    if (InstaCompete)
                    {
                        i            = currentText.Length - 2;
                        InstaCompete = false;
                        continue;
                    }
                }
                breakoutFlag = false;

                fader.TargetValue = 0.0f;
                IsComplete        = true;
            }
        }