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> PlayOut(Vector2 from, Vector2 outStart, Vector2 to, ITween outTween, IScheduler scheduler) { var velocity = outTween.CalculateStartVelocity(Vector2.Distance(to, outStart)); var linear = Easing.Linear(velocity); var compositeTween = new CompositeTween(new[] { Tuple.Create(linear, Vector2.Distance(outStart, from)), Tuple.Create(outTween, Vector2.Distance(to, outStart)), }); return(Play(new[] { from, outStart, to }, compositeTween, scheduler)); }
public static IObservable <float> PlayOut(float from, float outStart, float to, ITween outTween, IScheduler scheduler) { var velocity = outTween.CalculateStartVelocity(Mathf.Abs(to - outStart)); var linear = Easing.Linear(velocity); var compositeTween = new CompositeTween(new[] { Tuple.Create(linear, Mathf.Abs(outStart - from)), Tuple.Create(outTween, Mathf.Abs(to - outStart)), }); return(Play(new[] { from, outStart, to }, compositeTween, scheduler)); }