示例#1
0
        public FrameRange GetValidRange(FEvent evt)
        {
            int index = 0;

            for ( ; index < _events.Count; ++index)
            {
                if (_events[index] == evt)
                {
                    break;
                }
            }

            FrameRange range = new FrameRange(0, Sequence.Length);

            if (index > 0)
            {
                range.Start = _events[index - 1].End;
            }
            if (index < _events.Count - 1)
            {
                range.End = _events[index + 1].Start;
            }

            if (range.Length > evt.GetMaxLength())
            {
                range.Length = evt.GetMaxLength();
            }

            return(range);
        }
示例#2
0
        /// @brief Returns events at a given frame
        /// @param [in] t Frame
        /// @param [out] first First event, if there's 2 events it will be the one ending on that frame
        /// @param [out] second Second event, if there's 2 events it will be the one starting on that frame
        /// @return How many events are at frame \e t
        public int GetEventsAt(int t, out FEvent first, out FEvent second)
        {
            int index = 0;

            first  = null;
            second = null;

            for (int i = 0; i != _events.Count; ++i)
            {
                if (_events[i].Start <= t && _events[i].End >= t)
                {
                    if (index == 0)
                    {
                        first = _events[i];
                    }
                    else
                    {
                        second = _events[i];
                    }
                    ++index;
                }
                else if (_events[i].Start > t)                  // since they are ordered, no point in continuing
                {
                    break;
                }
            }

            return(index);
        }
示例#3
0
        public void Remove(FEvent evt)
        {
            _events.Remove(evt);
            evt.SetTrack(null);
            UpdateEventIds();

//			if( !Sequence.IsStopped )
//				Init();
        }
示例#4
0
        /// @overload
        public static FEvent Create(Type evtType, FrameRange range)
        {
            GameObject go = new GameObject(evtType.ToString());

            FEvent evt = (FEvent)go.AddComponent(evtType);

            evt._frameRange = new FrameRange(range.Start, range.End);

            evt.SetDefaultValues();

            return(evt);
        }
示例#5
0
        private bool HasAnimationOnFrame(int frame)
        {
            FEvent[] evts      = new FEvent[2];
            int      numEvents = GetEventsAt(frame, evts);

            if (numEvents == 0)
            {
                return(false);
            }

            return(((FPlayAnimationEvent)evts[0])._animationClip != null || (numEvents == 2 && ((FPlayAnimationEvent)evts[1])._animationClip != null));
        }
示例#6
0
        public FTrack Add <T>(FrameRange range) where T : FEvent
        {
            FTrack track = FTrack.Create <T>();

            Add(track);

            FEvent evt = FEvent.Create <T>(range);

            track.Add(evt);

            return(track);
        }
示例#7
0
        public bool CanAdd(FEvent evt)
        {
            foreach (FEvent e in _events)
            {
                // abort search, events are ordered!
                if (e.Start > evt.End)
                {
                    break;
                }

                if (evt.Collides(e))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#8
0
        public void Rebuild()
        {
            Transform t = transform;

            _events.Clear();

            for (int i = 0; i != t.childCount; ++i)
            {
                FEvent evt = t.GetChild(i).GetComponent <FEvent>();
                if (evt)
                {
                    evt.SetTrack(this);
                    _events.Add(evt);
                }
            }

            UpdateEventIds();
        }
示例#9
0
        public void Add(FEvent evt)
        {
            evt.SetTrack(this);

            for (int i = 0, limit = _events.Count; i != limit; ++i)
            {
                if (_events[i].Start > evt.End)
                {
                    _events.Insert(i, evt);
                    UpdateEventIds();
                    return;
                }
            }

            // didn't find a spot, add at the end
            evt.SetId(_events.Count);
            _events.Add(evt);
        }
示例#10
0
        /**
         * @brief Adds a new track to the timeline
         * @param range A track by default is added with 1 event
         * @T Event type that the track will hold
         * @sa RemoveTrack
         */
        public FTrack Add <T>(FrameRange range) where T : FEvent
        {
            FTrack track = FTrack.Create <T>();

            Add(track);
//			int id = _tracks.Count;
//
//			_tracks.Add( track );
//
//			track.SetTimeline( this );
//			track.SetId( id );
//
//			if( !Sequence.IsStopped )
//				track.Init();

            FEvent evt = FEvent.Create <T>(range);

            track.Add(evt);

            return(track);
        }
示例#11
0
        public bool CanAdd(FEvent evt, FrameRange newRange)
        {
            for (int i = 0; i != _events.Count; ++i)
            {
                if (_events[i].Start > newRange.End)
                {
                    break;
                }

                if (_events[i] == evt)
                {
                    continue;
                }

                if (_events[i].FrameRange.Collides(newRange))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#12
0
 /// @brief Compares events based on their start frame, basically used to order them.
 /// @param e1 Event
 /// @param e2 Event
 public static int Compare(FEvent e1, FEvent e2)
 {
     return(e1.Start.CompareTo(e2.Start));
 }
示例#13
0
 /// @brief Does the Event collides the \e e?
 public bool Collides(FEvent e)
 {
     return(_frameRange.Collides(e.FrameRange));
 }
示例#14
0
文件: FTrack.cs 项目: atom-chen/luxa
 public void Remove(FEvent evt)
 {
     _events.Remove(evt);
     evt.SetTrack(null);
     UpdateEventIds();
 }