コード例 #1
0
        /// <summary>
        /// Determine which rules to follow for container playback, and begin the appropriate function.
        /// </summary>
        /// <param name="activeEvent">The event to play.</param>
        protected void PlayContainer(ActiveEvent activeEvent)
        {
            if (activeEvent.AudioEvent.Container.Sounds.Length == 0)
            {
                Debug.LogErrorFormat(this, "Trying to play container \"{0}\" with no clips.", activeEvent.AudioEvent.Container);

                // Clean up the ActiveEvent before we discard it, so it will release its AudioSource(s).
                activeEvent.Dispose();
                return;
            }

            switch (activeEvent.AudioEvent.Container.ContainerType)
            {
            case AudioContainerType.Random:
                StartOneOffEvent(activeEvent);
                break;

            case AudioContainerType.Simultaneous:
                StartOneOffEvent(activeEvent);
                break;

            case AudioContainerType.Sequence:
                StartOneOffEvent(activeEvent);
                break;

            case AudioContainerType.ContinuousSequence:
                PlayContinuousSequenceContainer(activeEvent.AudioEvent.Container, activeEvent.PrimarySource, activeEvent);
                break;

            case AudioContainerType.ContinuousRandom:
                PlayContinuousRandomContainer(activeEvent.AudioEvent.Container, activeEvent.PrimarySource, activeEvent);
                break;

            default:
                Debug.LogErrorFormat(this, "Trying to play container \"{0}\" with an unknown AudioContainerType \"{1}\".", activeEvent.AudioEvent.Container, activeEvent.AudioEvent.Container.ContainerType);

                // Clean up the ActiveEvent before we discard it, so it will release its AudioSource(s).
                activeEvent.Dispose();
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Remove event from the currently active events.
        /// </summary>
        /// <param name="activeEvent">The persistent reference to the event as long as it is playing.</param>
        private void RemoveEventInstance(ActiveEvent activeEvent)
        {
            ActiveEvents.Remove(activeEvent);

            // Send message notifying user that sound is complete
            if (!string.IsNullOrEmpty(activeEvent.MessageOnAudioEnd))
            {
                activeEvent.AudioEmitter.SendMessage(activeEvent.MessageOnAudioEnd);
            }

            activeEvent.Dispose();
        }