Example #1
0
        /// <summary>
        /// The cutscene has been set to an arbitrary time by the user.
        /// Processing must take place to catch up to the new time.
        /// </summary>
        /// <param name="time">The new cutscene running time</param>
        public virtual void SetTime(float time)
        {
            float previousTime = elapsedTime;

            elapsedTime = time;

            TimelineItem[] items = GetTimelineItems();
            for (int i = 0; i < items.Length; i++)
            {
                // Check if it is a global event.
                GlobalEvent cinemaEvent = items[i] as GlobalEvent;
                if (cinemaEvent != null)
                {
                    if ((previousTime < cinemaEvent.Firetime && time >= cinemaEvent.Firetime) || (cinemaEvent.Firetime == 0f && previousTime <= cinemaEvent.Firetime && time > cinemaEvent.Firetime))
                    {
                        cinemaEvent.Trigger();
                    }
                    else if (previousTime > cinemaEvent.Firetime && elapsedTime <= cinemaEvent.Firetime)
                    {
                        cinemaEvent.Reverse();
                    }
                }

                // Check if it is a global action.
                GlobalAction action = items[i] as GlobalAction;
                if (action != null)
                {
                    action.SetTime((time - action.Firetime), time - previousTime);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Update the track to the given time
        /// </summary>
        /// <param name="time"></param>
        public virtual void UpdateTrack(float runningTime, float deltaTime)
        {
            if (mute)
            {
                return;
            }
            float previousTime = elapsedTime;

            elapsedTime = runningTime;

            TimelineItem[] items = GetTimelineItems();
            for (int i = 0; i < items.Length; i++)
            {
                GlobalEvent cinemaEvent = items[i] as GlobalEvent;
                if (cinemaEvent == null)
                {
                    continue;
                }

                if ((previousTime < cinemaEvent.Firetime || previousTime <= 0f) && elapsedTime >= cinemaEvent.Firetime)
                {
                    cinemaEvent.Trigger();
                }
                else if (previousTime >= cinemaEvent.Firetime && elapsedTime <= cinemaEvent.Firetime)
                {
                    cinemaEvent.Reverse();
                }
            }

            for (int i = 0; i < items.Length; i++)
            {
                GlobalAction action = items[i] as GlobalAction;
                if (action == null)
                {
                    continue;
                }
                if (((previousTime < action.Firetime || previousTime <= 0f) && elapsedTime >= action.Firetime) && elapsedTime < action.EndTime)
                {
                    action.Trigger();
                }
                else if ((previousTime <= action.EndTime) && (elapsedTime >= action.EndTime))
                {
                    action.End();
                }
                else if (previousTime > action.Firetime && previousTime <= action.EndTime && elapsedTime <= action.Firetime)
                {
                    action.ReverseTrigger();
                }
                else if ((previousTime > action.EndTime || previousTime >= action.Manager.Duration) && (elapsedTime > action.Firetime) && (elapsedTime <= action.EndTime))
                {
                    action.ReverseEnd();
                }
                else if ((elapsedTime > action.Firetime) && (elapsedTime < action.EndTime))
                {
                    float t = runningTime - action.Firetime;
                    action.UpdateTime(t, deltaTime);
                }
            }
        }