private IEnumerator Animate() { if (_delay > 0) { yield return(new WaitForSeconds(_delay)); } _setValue(_initialValue); // Play animation accordingly to the WrapMode defined in the animation curve if (_curve.postWrapMode == WrapMode.ClampForever) { yield return(CoroutineAnimation.AnimateOnce(_initialValue, _finalValue, _duration, _setValue, _curve)); } else if (_curve.postWrapMode == WrapMode.Loop) { yield return(CoroutineAnimation.AnimateLoop(_initialValue, _finalValue, _duration, _setValue, _curve)); } else if (_curve.postWrapMode == WrapMode.PingPong) { yield return(CoroutineAnimation.AnimatePingPong(_initialValue, _finalValue, _duration, _setValue, _curve)); } OnAnimationComplete.Invoke(); }
private IEnumerator DestroyCoroutine() { yield return(CoroutineAnimation.Animate( transform.localScale, Vector3.zero, .3f, (s) => transform.localScale = s)); Destroy(gameObject); }
public void Move(int toX, int toY, float time) { if (_moveCoroutine != null) { StopCoroutine(_moveCoroutine); } _piece.ChangeCoordinates(toX, toY); _moveCoroutine = StartCoroutine(CoroutineAnimation.Animate( transform.localPosition, _piece.Grid.GetCoordinatesWorldPosition(toX, toY), time, (p) => transform.localPosition = p)); }