예제 #1
0
 /// <summary>
 /// Update the track group to the current running time of the cutscene.
 /// </summary>
 /// <param name="time">The current running time</param>
 /// <param name="deltaTime">The deltaTime since the last update call</param>
 public virtual void UpdateTrackGroup(float time, float deltaTime)
 {
     TimelineTrack[] timelineTrackArr = GetTracks();
     for (int i = 0; i < timelineTrackArr.Length; i++)
     {
         TimelineTrack track = timelineTrackArr[i];
         track.UpdateTrack(time, deltaTime);
     }
 }
예제 #2
0
 static public int get_PlaybackMode(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         pushEnum(l, (int)self.PlaybackMode);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #3
0
 static public int get_TimelineItems(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         pushValue(l, self.TimelineItems);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #4
0
 static public int Optimize(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         self.Optimize();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #5
0
 static public int GetAllowedCutsceneItems(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         var ret = self.GetAllowedCutsceneItems();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #6
0
 static public int set_Ordinal(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.Ordinal = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #7
0
 static public int set_CanOptimize(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.CanOptimize = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #8
0
        /// <summary>
        /// The cutscene that this timeline item is associated with. Can return null.
        /// </summary>
        public Cutscene GetCutScene()
        {
#if IN_GAME
            return(CGManager.Instance.CurCutscene);
#else
            TimelineTrack track = GetTimelineTrack();
            if (track != null)
            {
                return(track.GetCutScene());
            }
            return(null);
#endif
        }
예제 #9
0
 static public int SetTime(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         self.SetTime(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #10
0
 static public int set_PlaybackMode(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         CinemaDirector.PlaybackMode  v;
         checkEnum(l, 2, out v);
         self.PlaybackMode = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #11
0
 static public int GetMilestones(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         var ret = self.GetMilestones(a1, a2);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #12
0
 /// <summary>
 /// Prepares the TrackGroup by caching all TimelineTracks.
 /// </summary>
 public virtual void Optimize()
 {
     if (canOptimize)
     {
         trackCache       = GetTracks();
         hasBeenOptimized = true;
     }
     TimelineTrack[] tracks = GetTracks();
     if (tracks != null)
     {
         for (int i = 0; i < tracks.Length; ++i)
         {
             TimelineTrack track = tracks[i];
             track.Optimize();
         }
     }
 }
예제 #13
0
        /// <summary>
        /// The track that this timeline item is associated with. Can return null.
        /// </summary>
        public TimelineTrack GetTimelineTrack()
        {
            TimelineTrack track = null;

            if (transform.parent != null)
            {
                track = base.transform.parent.GetComponentInParent <TimelineTrack>();
                if (track == null)
                {
                    Debug.LogError("No TimelineTrack found on parent!", this);
                }
            }
            else
            {
                Debug.LogError("Timeline Item has no parent!", this);
            }
            return(track);
        }
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List <Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
            // Get all the allowed Genres for this track group
            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];

            TimelineTrackAttribute[] tta = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(timelineTrack.GetType(), true);
            for (int i = 0; i < tta.Length; i++)
            {
                if (tta[i] != null)
                {
                    genres = tta[i].AllowedItemGenres;
                    break;
                }
            }

            Type[]      subTypes          = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineItem));
            List <Type> allowedTrackTypes = new List <Type>();

            for (int i = 0; i < subTypes.Length; i++)
            {
                CutsceneItemAttribute[] customAttributes = ReflectionHelper.GetCustomAttributes <CutsceneItemAttribute>(subTypes[i], true);
                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].Genres.Length; k++)
                        {
                            CutsceneItemGenre genre = customAttributes[j].Genres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedTrackTypes.Add(subTypes[i]);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedTrackTypes);
        }
예제 #15
0
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List <Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
            // Get all the allowed Genres for this track
            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];
            MemberInfo          info   = timelineTrack.GetType();

            foreach (TimelineTrackAttribute attribute in info.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedItemGenres;
                    break;
                }
            }

            List <Type> allowedItemTypes = new List <Type>();

            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineItem)))
            {
                foreach (CutsceneItemAttribute attribute in type.GetCustomAttributes(typeof(CutsceneItemAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (CutsceneItemGenre genre in attribute.Genres)
                        {
                            foreach (CutsceneItemGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedItemTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedItemTypes);
        }
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List<Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
            // Get all the allowed Genres for this track
            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];
            MemberInfo info = timelineTrack.GetType();

            foreach (TimelineTrackAttribute attribute in info.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedItemGenres;
                    break;
                }
            }

            List<Type> allowedItemTypes = new List<Type>();
            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineItem)))
            {
                foreach (CutsceneItemAttribute attribute in type.GetCustomAttributes(typeof(CutsceneItemAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (CutsceneItemGenre genre in attribute.Genres)
                        {
                            foreach (CutsceneItemGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedItemTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return allowedItemTypes;
        }
예제 #17
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
#if PROFILE_FILE
            Profiler.BeginSample("CharacterTrackGroup.Bake");
#endif // PROFILE_FILE
            if (Actor == null || Application.isPlaying)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();
            if (animator == null)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }

            List <RevertInfo> revertCache = new List <RevertInfo>();

            // Build the cache of revert info.
            var comps = this.GetComponentsInChildren <MonoBehaviour>();
            for (var i = 0; i < comps.Length; ++i)
            {
                MonoBehaviour mb         = comps[i];
                IRevertable   revertable = mb as IRevertable;
                if (revertable != null)
                {
                    revertCache.AddRange(revertable.CacheState());
                }
            }

            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            float frameRate  = 30;
            int   frameCount = (int)((Cutscene.Duration * frameRate) + 2);
            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                var tracks = GetTracks();
                for (int j = 0; j < tracks.Length; ++j)
                {
                    TimelineTrack track = tracks[j];
                    if (!(track is DialogueTrack))
                    {
                        track.UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                    }
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;

            for (int i = 0; i < revertCache.Count; ++i)
            {
                RevertInfo revertable = revertCache[i];
                if (revertable != null)
                {
                    if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                        (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                    {
                        revertable.Revert();
                    }
                }
            }

            base.Initialize();
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
        }
    /// <summary>
    /// Create a new Timeline Item (Cutscene Item)
    /// </summary>
    /// <param name="timelineTrack">The track that this item will be attached to.</param>
    /// <param name="type">the type of the new item.</param>
    /// <param name="label">The name of the new item.</param>
    /// <returns>The newly created Cutscene Item. Reminder: Register an Undo.</returns>
    internal static TimelineItem CreateCutsceneItem(TimelineTrack timelineTrack, Type type, string label, float firetime)
    {
        GameObject itemGO = new GameObject(label, type);
        TimelineItem ti = itemGO.GetComponent<TimelineItem>();
        ti.SetDefaults();

        // Find an appropriate firetime/duration for it.
        if (type.IsSubclassOf(typeof(TimelineActionFixed)))
        {
            // The new timeline item is an action of fixed length.
            TimelineActionFixed newAction = ti as TimelineActionFixed;

            SortedDictionary<float, TimelineActionFixed> sortedClips = new SortedDictionary<float, TimelineActionFixed>();
            foreach (TimelineItem current in timelineTrack.TimelineItems)
            {
                TimelineActionFixed action = current as TimelineActionFixed;
                if (action == null) continue;
                sortedClips.Add(action.Firetime, action);
            }

            float latestTime = firetime;
            float length = newAction.ItemLength;
            foreach (TimelineActionFixed a in sortedClips.Values)
            {
                if (!(latestTime < a.Firetime && latestTime + length <= a.Firetime))
                {
                    latestTime = a.Firetime + a.Duration;
                }
            }

            newAction.Firetime = latestTime;
        }
        else if (type.IsSubclassOf(typeof(TimelineAction)))
        {
            // The new timeline item is an action with arbitrary length.
            TimelineAction newAction = ti as TimelineAction;

            SortedDictionary<float, TimelineAction> sortedActions = new SortedDictionary<float, TimelineAction>();
            foreach (TimelineItem current in timelineTrack.TimelineItems)
            {
                TimelineAction action = current as TimelineAction;
                if (action == null) continue;
                sortedActions.Add(action.Firetime, action);
            }

            float latestTime = firetime;
            float length = newAction.Duration;
            foreach (TimelineAction a in sortedActions.Values)
            {
                if (latestTime >= a.Firetime)
                {
                    latestTime = Mathf.Max(latestTime, a.Firetime + a.Duration);
                }
                else
                {
                    length = a.Firetime - latestTime;
                    break;
                }
            }

            newAction.Firetime = latestTime;
            newAction.Duration = length;
        }
        else
        {
            ti.Firetime = firetime;
        }

        itemGO.transform.parent = timelineTrack.transform;
        return ti;
    }
예제 #19
0
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List <Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
            var         timelineTrackType = timelineTrack.GetType();
            List <Type> allowedItemTypes;

            if (_DicAllowedItemTypes.TryGetValue(timelineTrackType, out allowedItemTypes))
            {
                return(allowedItemTypes);
            }
#if BakeReflection
            // Get all the allowed Genres for this track group
            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];

            TimelineTrackAttribute[] tta = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(timelineTrackType, true);
            for (int i = 0; i < tta.Length; i++)
            {
                if (tta[i] != null)
                {
                    genres = tta[i].AllowedItemGenres;
                    break;
                }
            }

            Type[] subTypes = GetAllSubTypes(typeof(TimelineItem));
            allowedItemTypes = new List <Type>();
            for (int i = 0; i < subTypes.Length; i++)
            {
                CutsceneItemAttribute[] customAttributes;

                var subType = subTypes[i];
                List <CutsceneItemAttribute> cache = null;
                if (_CacheCIAttribute.TryGetValue(subType, out cache))
                {
                    customAttributes = cache.ToArray();
                }
                else
                {
                    customAttributes = ReflectionHelper.GetCustomAttributes <CutsceneItemAttribute>(subType, true);
                    _CacheCIAttribute.Add(subType, new List <CutsceneItemAttribute>(customAttributes));
                }

                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].Genres.Length; k++)
                        {
                            CutsceneItemGenre genre = customAttributes[j].Genres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedItemTypes.Add(subType);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            _DicAllowedItemTypes.Add(timelineTrackType, allowedItemTypes);
#endif
            return(allowedItemTypes);
        }
예제 #20
0
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List <Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
#if PROFILE_FILE
            Profiler.BeginSample("DirectorRuntimeHelper.GetAllowedItemTypes");
#endif // PROFILE_FILE
            // Get all the allowed Genres for this track
            var         t = timelineTrack.GetType();
            List <Type> allowedItemTypes = null;
            if (_allowedItemTypes.TryGetValue(t, out allowedItemTypes))
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return(allowedItemTypes);
            }

            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];

            var list   = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(t, true);
            var length = list.Length;
            for (var i = 0; i < length; i++)
            {
                var attribute = list[i];

                if (attribute != null)
                {
                    genres = attribute.AllowedItemGenres;
                    break;
                }
            }

            allowedItemTypes = new List <Type>();
            var typeList = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineItem));
            length = typeList.Length;
            var lengthGenres = genres.Length;
            for (var i = 0; i < length; i++)
            {
                var type    = typeList[i];
                var list2   = ReflectionHelper.GetCustomAttributes <CutsceneItemAttribute>(type, true);
                var length2 = list2.Length;
                for (var j = 0; j < length2; j++)
                {
                    var attribute = list2[j];
                    if (attribute != null)
                    {
                        var list3   = attribute.Genres;
                        var length3 = list3.Length;
                        for (var k = 0; k < length3; k++)
                        {
                            for (var x = 0; x < lengthGenres; x++)
                            {
                                if (list3[k] == genres[x])
                                {
                                    allowedItemTypes.Add(type);
                                    break;
                                }
                            }
                        }

                        break;
                    }
                }
            }

#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
            _allowedItemTypes[t] = allowedItemTypes;
            return(allowedItemTypes);
        }
 public ContextData(Type type, Type pairedType, TimelineTrack track, string category, string label)
 {
     Type = type;
     PairedType = pairedType;
     Track = track;
     Category = category;
     Label = label;
 }
 public PasteContext(Vector2 mousePosition, TimelineTrack track)
 {
     this.mousePosition = mousePosition;
     this.track = track;
 }
 public static bool IsTrackItemValidForTrack(Behaviour behaviour, TimelineTrack track)
 {
     bool retVal = false;
     if (track.GetType()==(typeof(ShotTrack)))
     {
         if (behaviour.GetType() == (typeof(CinemaShot)))
         {
             retVal = true;
         }
     }
     else if (track.GetType()==(typeof(AudioTrack)))
     {
         if (behaviour.GetType() == (typeof(CinemaAudio)))
         {
             retVal = true;
         }
     }
     else if (track.GetType()==(typeof(GlobalItemTrack)) || track.GetType().IsSubclassOf(typeof(GlobalItemTrack)))
     {
         if (behaviour.GetType() == typeof(CinemaShot) || (behaviour.GetType().IsSubclassOf(typeof(CinemaAudio))))
         {
             retVal = false;
         }
         else if (behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaGlobalEvent)))
         {
             retVal = true;
         }
     }
     else if (track.GetType()==(typeof(ActorItemTrack)) || track.GetType().IsSubclassOf(typeof(ActorItemTrack)))
     {
         if (behaviour.GetType().IsSubclassOf(typeof(CinemaActorAction)) || behaviour.GetType().IsSubclassOf(typeof(CinemaActorEvent)))
         {
             retVal = true;
         }
     }
     else if (track.GetType() == (typeof(CurveTrack)) || track.GetType().IsSubclassOf(typeof(CurveTrack)))
     {
         if (behaviour.GetType()==(typeof(CinemaActorClipCurve)))
         {
             retVal = true;
         }
     }
     else if (track.GetType() == (typeof(MultiCurveTrack)) || track.GetType().IsSubclassOf(typeof(MultiCurveTrack)))
     {
         if (behaviour.GetType()==(typeof(CinemaMultiActorCurveClip)))
         {
             retVal = true;
         }
     }
     return retVal;
 }
예제 #24
0
        /// <summary>
        /// Returns a list of Cutscene Item types that are associated with the given Track.
        /// </summary>
        /// <param name="timelineTrack">The track to look up.</param>
        /// <returns>A list of valid cutscene item types.</returns>
        public static List <Type> GetAllowedItemTypes(TimelineTrack timelineTrack)
        {
            // Get all the allowed Genres for this track
            CutsceneItemGenre[] genres = new CutsceneItemGenre[0];
            MemberInfo          info   = timelineTrack.GetType();
            {
                var __array3       = info.GetCustomAttributes(typeof(TimelineTrackAttribute), true);
                var __arrayLength3 = __array3.Length;
                for (int __i3 = 0; __i3 < __arrayLength3; ++__i3)
                {
                    var attribute = (TimelineTrackAttribute)__array3[__i3];
                    {
                        if (attribute != null)
                        {
                            genres = attribute.AllowedItemGenres;
                            break;
                        }
                    }
                }
            }
            List <Type> allowedItemTypes = new List <Type>();

            {
                var __array4       = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineItem));
                var __arrayLength4 = __array4.Length;
                for (int __i4 = 0; __i4 < __arrayLength4; ++__i4)
                {
                    var type = (Type)__array4[__i4];
                    {
                        {
                            var __array12       = type.GetCustomAttributes(typeof(CutsceneItemAttribute), true);
                            var __arrayLength12 = __array12.Length;
                            for (int __i12 = 0; __i12 < __arrayLength12; ++__i12)
                            {
                                var attribute = (CutsceneItemAttribute)__array12[__i12];
                                {
                                    if (attribute != null)
                                    {
                                        {
                                            // foreach(var genre in attribute.Genres)
                                            var __enumerator17 = (attribute.Genres).GetEnumerator();
                                            while (__enumerator17.MoveNext())
                                            {
                                                var genre = (CutsceneItemGenre)__enumerator17.Current;
                                                {
                                                    {
                                                        var __array19       = genres;
                                                        var __arrayLength19 = __array19.Length;
                                                        for (int __i19 = 0; __i19 < __arrayLength19; ++__i19)
                                                        {
                                                            var genre2 = (CutsceneItemGenre)__array19[__i19];
                                                            {
                                                                if (genre == genre2)
                                                                {
                                                                    allowedItemTypes.Add(type);
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(allowedItemTypes);
        }