static public IEnumerator TweenLocalPosition_cr(Transform target, Vector3 start, Vector3 end, float time, EaseUtils.EaseType ease, CupheadTime.Layer timeLayer, TweenUpdateHandler updateCallback, TweenCompletedHandler endCallback = null) { target.localPosition = start; float t = 0f; while (t < time) { float val = t / time; float x = EaseUtils.Ease(ease, start.x, end.x, val); float y = EaseUtils.Ease(ease, start.y, end.y, val); float z = EaseUtils.Ease(ease, start.z, end.z, val); target.SetLocalPosition(x, y, z); updateCallback?.Invoke(val); t += CupheadTime.Delta[timeLayer]; yield return(null); } target.localPosition = end; updateCallback?.Invoke(1f); endCallback?.Invoke(); yield return(null); }
static public IEnumerator TweenSpriteRendererColor_cr(SpriteRenderer renderer, Color start, Color end, float time, EaseUtils.EaseType ease, CupheadTime.Layer timeLayer, TweenCompletedHandler endCallback = null) { float t = 0f; Color c = start; while (t < time) { float val = t / time; c.r = EaseUtils.Ease(ease, start.r, end.r, val); c.g = EaseUtils.Ease(ease, start.g, end.g, val); c.b = EaseUtils.Ease(ease, start.b, end.b, val); c.a = EaseUtils.Ease(ease, start.a, end.a, val); renderer.color = c; t += CupheadTime.Delta[timeLayer]; yield return(null); } endCallback?.Invoke(); yield return(null); }
static public IEnumerator TweenScale_cr(Transform transform, Vector2 start, Vector2 end, float time, EaseUtils.EaseType ease, CupheadTime.Layer timeLayer, TweenCompletedHandler endCallback = null) { transform.SetScale(start.x, start.y, null); float t = 0f; while (t < time) { float val = t / time; float x = EaseUtils.Ease(ease, start.x, end.x, val); float y = EaseUtils.Ease(ease, start.y, end.y, val); transform.SetScale(x, y, null); t += CupheadTime.Delta[timeLayer]; yield return(null); } transform.SetScale(end.x, end.y, null); endCallback?.Invoke(); yield return(null); }
static public IEnumerator TweenValue_cr(float start, float end, float time, EaseUtils.EaseType ease, TweenUpdateHandler updateCallback, TweenCompletedHandler endCallback = null) { float t = 0f; while (t < time) { float val = t / time; updateCallback?.Invoke(EaseUtils.Ease(ease, start, end, val)); t += CupheadTime.GlobalDelta; yield return(null); } updateCallback?.Invoke(end); endCallback?.Invoke(); yield return(null); }