public override void Start() { if (_actuator.Actuators.Count < 2) { return; } Frames.Clear(); var orderedActuators = new List<IStateMachine>(_actuator.Actuators); if (!_isForward) { orderedActuators.Reverse(); } double frameLength = _duration.TotalMilliseconds/(orderedActuators.Count - 1); for (int i = 0; i < orderedActuators.Count; i++) { var actuator = orderedActuators[i]; var offset = TimeSpan.FromMilliseconds(frameLength * i); WithFrame(new Frame().WithTargetState(actuator, _targetState).WithStartTime(offset)); } var lastFrame = new Frame().WithStartTime(_duration); foreach (var actuator in _actuator.Actuators) { lastFrame.WithTargetState(actuator, _targetState); } WithFrame(lastFrame); base.Start(); }
public Animation WithFrame(Frame frame) { if (frame == null) throw new ArgumentNullException(nameof(frame)); Frames.Add(frame); return this; }