Ejemplo n.º 1
0
 private void PlayRandomomponent(ComponentInstance zComponentInstance)
 {
     if (_playMode == RandomComponentPlayMode.Random)
     {
         int index = _shuffleBag.get();
         _selectedComponent = _components[index];
     }
     else
     {
         int num = -1;
         if (!_shareRandomNoRepeatHistory)
         {
             num = GetNextRandomNoRepeatIndex();
         }
         else
         {
             RandomComponent randomComponent = base.ComponentHolder as RandomComponent;
             if ((bool)randomComponent)
             {
                 num = randomComponent.GetNextRandomNoRepeatIndex();
             }
         }
         if (num < 0)
         {
             return;
         }
         _selectedComponent = _components[num];
     }
     if (_selectedComponent != null)
     {
         _selectedComponent.PlayInternal(zComponentInstance, 0f, 0.5f);
     }
 }
Ejemplo n.º 2
0
        AudioClip GetAudioClip(string eventName)
        {
            Fabric.AudioComponent audioComponent = null;

            if (eventToComponent.TryGetValue(eventName, out audioComponent))
            {
                var random = audioComponent as RandomAudioClipComponent;

                if (random != null)
                {
                    return(random._audioClips.GetRandom());
                }

                return(audioComponent.AudioClip);
            }

            Fabric.RandomComponent rndComponent = null;

            if (eventToRndComponent.TryGetValue(eventName, out rndComponent))
            {
                var child = rndComponent.GetChildComponents();

                Fabric.AudioComponent c = child.GetRandom() as AudioComponent;
                if (c != null)
                {
                    return(c.AudioClip);
                }
            }

            return(null);
        }