Esempio n. 1
0
 public static ICompletable ScaleTo(this Transform This, float target, float duration, IEaser easer = null) =>
 Range(() => This.localScale, new Vector3(target, target, target), duration, easer)
 .Do(x => This.localScale = x)
 .AsCompletable();
Esempio n. 2
0
 public static ICompletable RotateTo(this Transform This, Quaternion target, float duration, IEaser easer = null) =>
 Range(() => This.localRotation, target, duration, easer)
 .Do(x => This.localRotation = x)
 .AsCompletable();
Esempio n. 3
0
 public static ICompletable WorldRotateTo(this Transform This, Vector3 target, float duration, IEaser easer = null) =>
 Range(() => This.rotation, Quaternion.Euler(target), duration, easer)
 .Do(x => This.rotation = x)
 .AsCompletable();
Esempio n. 4
0
 public static ICompletable WorldMoveTo(this Transform This, Vector3 target, float duration, IEaser easer = null) =>
 Range(() => This.position, target, duration, easer)
 .Do(x => This.position = x)
 .AsCompletable();
Esempio n. 5
0
 public static IObservable <float> Range(float duration, IEaser easer = null) =>
 new TweenObservable(duration, easer);
Esempio n. 6
0
 public static ICompletable MoveAnchorYTo(this RectTransform This, float target, float duration, IEaser easer = null) =>
 Range(() => This.anchoredPosition.y, target, duration, easer)
 .Do(y => This.anchoredPosition = This.anchoredPosition.WithY(y))
 .AsCompletable();
 public TweenVector3ToShiftingTargetCompletable(IReactiveProperty <Vector3> property, IObservable <Vector3> target, float duration, IEaser easer = null) :
     base(property, target, duration, easer)
 {
 }
Esempio n. 8
0
 public TweenObservable(float duration, IEaser easer = null)
 {
     _duration = duration;
     _easer    = easer;
 }
Esempio n. 9
0
 protected TweenWithInitialVelocityObservableBase(Func <T> sourceSelector, Func <T> velocitySelector, T target, float duration, IEaser easer)
 {
     _sourceSelector   = sourceSelector;
     _velocitySelector = velocitySelector;
     _target           = target;
     _duration         = duration;
     _easer            = easer ?? Easer.Linear;
 }
Esempio n. 10
0
 /// <summary>
 /// Eases values of This observable using given ease function
 /// </summary>
 public static IObservable <float> Ease(this IObservable <float> This, IEaser easer) =>
 This.Select(easer.Ease);
Esempio n. 11
0
 public TweenVector2WithInitialVelocityObservable(Func <Vector2> sourceSelector, Func <Vector2> velocitySelector, Vector2 target, float duration, IEaser easer) :
     base(sourceSelector, velocitySelector, target, duration, easer)
 {
 }
Esempio n. 12
0
 /// <summary>
 /// Eases this value using given easer
 /// </summary>
 public static float Ease(this float This, IEaser ease) =>
 ease.Ease(This);
Esempio n. 13
0
 /// <summary>
 /// Makes this easer animate backwards within the same time span
 /// </summary>
 public static IEaser Reversed(this IEaser This) =>
 new Easer(t => This.Ease(1 - t));
Esempio n. 14
0
 /// <summary>
 /// Makes this easer animate forwards then backwards within the same time span
 /// </summary>
 public static IEaser PingPong(this IEaser This) =>
 new Easer(t => This.Ease(
               t <= 0.5f
                             ? t * 2
                             : 1 - (t - 0.5f) * 2));
Esempio n. 15
0
 public static IObservable <float> Range(Func <float> selector, float target, float duration, IEaser easer = null) =>
 Observable.Defer(() =>
 {
     var source = selector();
     return(source.IsAlmostEqualTo(target)
             ? Observable.Return(target)
             : Range(duration, easer).Lerp(source, target));
 });
Esempio n. 16
0
 public static ICompletable FadeOut(this CanvasGroup This, float duration, IEaser easer = null) =>
 Range(() => This.alpha, 0f, duration, easer)
 .Do(x => This.alpha = x)
 .AsCompletable();
Esempio n. 17
0
 public static ICompletable MoveAnchorTo(this RectTransform This, Vector2 target, float duration, IEaser easer = null) =>
 Range(() => This.anchoredPosition, target, duration, easer)
 .Do(x => This.anchoredPosition = x)
 .AsCompletable();
Esempio n. 18
0
 public static ICompletable TweenColorTo(this Graphic This, Color target, float duration, IEaser easer = null) =>
 Range(() => This.color, target, duration, easer)
 .Do(x => This.color = x)
 .AsCompletable();
Esempio n. 19
0
		protected Tween (TweenDescriptor aDescriptor)
		{
			_descriptor = aDescriptor;

			_tweenID = Tweens.Count;	
			_startValue = aDescriptor.fromValue; 
			_endValue = aDescriptor.toValue;
		
			_range = GetRange (_startValue, _endValue);
			if (!aDescriptor.baseOnSpeed) {
				_duration = aDescriptor.time;
			} else {
				_duration = GetDuration (aDescriptor.speed, _startValue, _endValue); 
			}

			_easer = GetEaser (aDescriptor.easeType); 	
			_progress = 0.0f;
			_delayTimeStamp = Time.timeSinceLevelLoad; 	
			_delay = aDescriptor.delay;
			_yoyo = aDescriptor.yoyo;
			_loopCount = 0;
			_loops = aDescriptor.loops;
		
			if (_yoyo && _loops == 0) //if its a yoyo effect, the loop will be atleast 1:
				_loops = 1;		
			
			_reversing = false;
		
			if (aDescriptor.updateMethod != null)
				UpdateEvent += aDescriptor.updateMethod;

			if (aDescriptor.completeMethod != null)
				CompleteEvent += aDescriptor.completeMethod;

			Tweens.Add (this);
			
			
			TweenController.Singleton.UpdateEvent += Update;
			Play (); 
		}
 protected override ICompletable Tween(IReactiveProperty <Vector3> property, Vector3 target, float duration, Vector3 velocity, IEaser easer) =>
 property.TweenTo(target, duration, () => velocity, easer);