예제 #1
0
        protected override void DoSet(bool paused)
        {
            base.DoSet(paused);

            if (inDelay_)
            {
                return;
            }

            if (newClip_)
            {
                switch (playType_)
                {
                case PlayIfClear:
                    source_.PlayIfClear(currentClip_);
                    break;

                case PlayNow:                          // fall-through
                default:
                    source_.PlayNow(currentClip_);
                    break;
                }

                if (source_.playingClip == currentClip_)
                {
                    source_.audioSource.time = 0;
                    newClip_ = false;
                }
            }
        }
예제 #2
0
 /**
  * Play the assigned audio clip with optional "if clear" param.
  */
 public void Play(AudioSourceControl receiver = null, bool ifClear = false, bool clearQueue = false)
 {
     if (SourceClip == null)
     {
         return;
     }
     if ((UnityEngine.Object)receiver != (UnityEngine.Object)null)
     {
         Receiver = receiver;
     }
     if (ifClear)
     {
         Receiver.PlayIfClear(SourceClip);
     }
     else
     {
         if (clearQueue)
         {
             Receiver.PlayNowClearQueue(SourceClip);
         }
         else
         {
             Receiver.PlayNow(SourceClip);
         }
     }
 }
예제 #3
0
    public void Update()
    {
        if (_clips == null || Time.time < _next)
        {
            return;
        }

        try
        {
            var intensity = (int)Mathf.Round(_intensityJSON.val + UnityEngine.Random.Range(-_variabilityJSON.val, _variabilityJSON.val));

            List <NamedAudioClip> clips;
            if (!_clips.TryGetValue(intensity, out clips))
            {
                return;
            }

            var clip = clips[UnityEngine.Random.Range(0, clips.Count - 1)];

            _headAudioSource.PlayIfClear(clip);
            _next = Time.time + clip.sourceClip.length + _paddingJSON.val;
        }
        catch (Exception e)
        {
            SuperController.LogError($"{nameof(Cornwall)}.{nameof(Update)}: {e}");
        }
    }