public static IObservable <Vector2> PlayInOut(Vector2 from, Vector2 inEnd, Vector2 outStart, Vector2 to, ITween inTween, ITween outTween, IScheduler scheduler) { var inVelocity = inTween.CalculateFinishVelocity(Vector2.Distance(inEnd, from)).PerSecond; var outVelocity = outTween.CalculateStartVelocity(Vector2.Distance(to, outStart)).PerSecond; ITween linearTween; if (Math.Abs(inVelocity - outVelocity) < EQUAL_DELTA) { linearTween = TweenMotion.Uniform((float)((inVelocity + outVelocity) / 2.0)); } else { var accel = (outVelocity * outVelocity - inVelocity * inVelocity) / (2.0f * Vector2.Distance(outStart, inEnd)); linearTween = TweenMotion.Acceleration((float)accel, (float)inVelocity); } var compositeTween = new CompositeTween(new[] { Tuple.Create(inTween, Vector2.Distance(inEnd, from)), Tuple.Create(linearTween, Vector2.Distance(outStart, inEnd)), Tuple.Create(outTween, Vector2.Distance(to, outStart)), }); return(Play(new[] { from, inEnd, outStart, to }, compositeTween, scheduler)); }
public static IObservable <Vector2> PlayIn(Vector2 from, Vector2 inEnd, Vector2 to, ITween inTween, IScheduler scheduler) { var velocity = inTween.CalculateFinishVelocity(Vector2.Distance(inEnd, from)); var linear = Easing.Linear(velocity); var compositeTween = new CompositeTween(new[] { Tuple.Create(inTween, Vector2.Distance(inEnd, from)), Tuple.Create(linear, Vector2.Distance(to, inEnd)), }); return(Play(new[] { from, inEnd, to }, compositeTween, scheduler)); }
public static IObservable <float> PlayIn(float from, float inEnd, float to, ITween inTween, IScheduler scheduler) { var velocity = inTween.CalculateFinishVelocity(Mathf.Abs(inEnd - from)); var linear = Easing.Linear(velocity); var compositeTween = new CompositeTween(new[] { Tuple.Create(inTween, Mathf.Abs(inEnd - from)), Tuple.Create(linear, Mathf.Abs(to - inEnd)), }); return(Play(new[] { from, inEnd, to }, compositeTween, scheduler)); }