Esempio n. 1
0
 /// <summary> Destructor - remove syncGroup reference </summary>
 internal void OnDestroy()
 {
     if (m_sequence != null)
     {
         if (!string.IsNullOrEmpty(m_sequence.m_syncGroup))
         {
             SyncGroup sg = SyncGroup.Get(m_sequence.m_syncGroup);
             if (sg != null)
             {
                 sg.Remove(this);
             }
         }
     }
 }
Esempio n. 2
0
        internal static SyncGroup Get(string groupName)
        {
            if (string.IsNullOrEmpty(groupName))
            {
                return(null);
            }
            SyncGroup ret = _allSyncGroups.Find(delegate(SyncGroup group) {
                return(groupName == group.m_name);
            });

            if (ret == null && !string.IsNullOrEmpty(groupName))
            {
                ret = new SyncGroup(groupName);
                _allSyncGroups.Add(ret);
            }
            return(ret);
        }
Esempio n. 3
0
        /// <summary> To be called every time a Modifier changes so the properties can be recalculated </summary>
        public void UpdateModifiers()
        {
            m_hasBeenUpdated = true;
            List <ClipData> clips = new List <ClipData>(m_clipData);

            for (int m = 0; m < m_modifiers.Length; ++m)
            {
                if (m_modifiers[m] == null)
                {
                    continue;
                }
                m_modifiers[m].UpdateFadeValue();
                if (m_modifiers[m].m_modRandomizeVolume)
                {
                    if (m_modifiers[m].FadeValue > 0.5f)
                    {
                        _randomizeVolumeModIsSet = true;
                        _randomizeVolumeMod      = m_modifiers[m].m_randomizeVolume;
                    }
                }
                if (m_modifiers[m].m_modRandomizePlaybackSpeed)
                {
                    if (m_modifiers[m].FadeValue > 0.5f)
                    {
                        _randomizePlaybackSpeedModIsSet = true;
                        _randomizePlaybackSpeedMod      = m_modifiers[m].m_randomizePlaybackSpeed;
                    }
                }
                if (m_modifiers[m].m_modClips)
                {
                    if (m_modifiers[m].FadeValue >= 0.5f)   //can only change the array fully or not at all ... so do it at half way up
                    {
                        if (m_modifiers[m].m_modClipsType == ClipModType.Add)
                        {
                            clips.AddRange(m_modifiers[m].m_clipData);
                        }
                        else if (m_modifiers[m].m_modClipsType == ClipModType.Remove)
                        {
                            foreach (ClipData clip in m_modifiers[m].m_clipData)
                            {
                                if (clip.m_clip != null)
                                {
                                    clips.RemoveAll(delegate(ClipData c) {
                                        return(c.m_clip == clip.m_clip);
                                    });
                                }
                            }
                        }
                        else     //Replace
                        {
                            clips = new List <ClipData>(m_modifiers[m].m_clipData);
                        }
                    }
                }
            }
            float newLength = 0f;

            clips.RemoveAll(c => c.m_clip == null);
            foreach (ClipData clip in clips)
            {
                newLength += (AmbienceManager.GetAudioData(clip.m_clip).Length - m_crossFade) * PlaybackSpeed;
                //newLength += (clip.length - m_crossFade) * PlaybackSpeed;
            }
            if (newLength != TotalLength)
            {
                TotalLength = newLength;
                if (!string.IsNullOrEmpty(m_syncGroup))
                {
                    SyncGroup.Get(m_syncGroup).UpdateLength();
                }
            }
            lock (ClipsLockHandle)
                Clips = clips.ToArray();
        }