public void Update(float elapsedTime) { if (!Running) { return; } _currentTime += elapsedTime; if (_currentTime >= _currentStep.Duration) { _currentTime -= _currentStep.Duration; if (_workItems.Count == 0) { if (_looping) { _workItems = new Queue <StoryboardStep <T> >(_steps); } else { Running = false; } } else { _currentStep = _workItems.Dequeue(); } } _currentValue = GetValue(_currentTime, _currentStep); }
public void Begin(bool looping) { _looping = looping; _workItems = new Queue <StoryboardStep <T> >(_steps); _currentStep = _workItems.Dequeue(); _currentTime = 0; _currentValue = GetValue(_currentTime, _currentStep); Running = true; }
protected abstract T GetValue(float elapsedTime, StoryboardStep <T> step);
protected override Vector2 GetValue(float elapsedTime, StoryboardStep <Vector2> step) { return(new Vector2(MathHelper.Lerp(step.StartValue.X, step.TargetValue.X, elapsedTime / step.Duration), MathHelper.Lerp(step.StartValue.Y, step.TargetValue.Y, elapsedTime / step.Duration))); }
protected override float GetValue(float elapsedTime, StoryboardStep <float> step) { return(MathHelper.Lerp(step.StartValue, step.TargetValue, elapsedTime / step.Duration)); }