using System; using System.Collections.Generic; using System.Text; using SalsaModel.Scheduling; namespace SalsaModel.Actions { class HalfTurn : IAction { readonly SalsaMover.TurnDirection _direction; readonly PositionModel.Side _stepWith; readonly double _stepDistance; readonly SalsaMover _mover; double _initAngle; double _addToAngle; public HalfTurn(SalsaMover mover, PositionModel.Side stepWith, double distance, SalsaMover.TurnDirection direction) { _mover = mover; _stepWith = stepWith; _stepDistance = distance; _direction = direction; } TimeLine _timeLine = new TimeLine(); public void Start() { _initAngle = _mover.Model.ForwardUnit().XYOrientation(); _addToAngle = (_direction == SalsaMover.TurnDirection.Right ? Math.PI : -Math.PI); _timeLine.Add(0, 1, new MoveFootAction(_mover, _stepWith, _stepDistance)); CubanMotionAction.AddTo(_timeLine, 0, 1, _mover, _stepWith, _stepDistance, _addToAngle); _prev = -1; _timeLine.RunActions(_prev, 0); _prev = 0; } double _prev; public void Update(double now) { _mover.RotateFootAroundToeBy(PositionModel.Side.Left, _addToAngle * (now - _prev)); _mover.RotateFootAroundToeBy(PositionModel.Side.Right, _addToAngle * (now - _prev)); _timeLine.RunActions(_prev, now); _prev = now; } public void End() { } public string DescriptiveCode { get { return "Half-turn"; } } } }