Beispiel #1
0
        // Internal update function, i.e. does the actual update of the sequence
        protected virtual void InternalUpdate(float time)
        {
//			float delta = time - _lastUpdateTime;
//			float timePerFrame = InverseFrameRate;
//			if( delta >= timePerFrame )
//			{
//				int numFrames = Mathf.RoundToInt(delta / timePerFrame);
//				SetCurrentFrame( _currentFrame + numFrames );
//				_lastUpdateTime = time - (delta - (timePerFrame * numFrames));
//			}

            float delta = time - _lastUpdateTime;

            if (delta != 0)
            {
                SetCurrentTimeInternal(_currentTime + delta * Speed);

                /// @TODO take into account the "time lost" with clamping
                if (_isPlayingForward)
                {
                    if (_currentTime == LengthTime)
                    {
                        OnFinishedCallback.Invoke(this);

                        if (_loop)
                        {
                            Stop();
                            Play();
                        }
                        else
                        {
                            Pause();
                        }
                    }
                }
                else
                {
                    if (_currentTime == 0)
                    {
                        OnFinishedCallback.Invoke(this);

                        if (_loop)
                        {
                            Stop();
                            Play();                             // @TODO Play backwards
                        }
                        else
                        {
                            Pause();
                        }
                    }
                }

                _lastUpdateTime = time;
            }
        }
 public ThreadRunner(string file, OnFinishedCallback onFinished)
 {
     this.file       = file;
     this.onFinished = onFinished;
 }