IEnumerator Interpolation(Easings.Functions mode, float duration) { if (-EPSILON < duration && duration < EPSILON) { yield break; } yield return(null); var t = (duration > 0f ? 0f : 1f); var ds = 1f / duration; NotifyOnBegin(t); while (true) { t += Time.deltaTime * ds; if (t < 0f || 1f < t) { break; } Func(Easings.Interpolate(t, mode)); yield return(null); } Func(Easings.Interpolate(Mathf.Clamp01(t), mode)); NotifyOnEnd(t); _coroutine = null; }
private void CurveLaserTowardTargets() { Quaternion minRotation = Quaternion.identity; float minDeltaAngle = float.MaxValue; foreach (Transform laserTarget in laserTargets_) { Vector3 delta = (laserTarget.position - this.transform.position).normalized; delta = delta.SetY(0.0f); if (delta.magnitude <= Mathf.Epsilon) { continue; } Quaternion rotationToPlayer = Quaternion.LookRotation(delta.normalized); float deltaAngle = Quaternion.Angle(this.transform.rotation, rotationToPlayer); if (deltaAngle < minDeltaAngle) { minDeltaAngle = deltaAngle; minRotation = rotationToPlayer; } } float rotationMultiplier = Mathf.Clamp(1.0f - Easings.CubicEaseIn(minDeltaAngle / kRotationMaxAngle), 0.0f, 1.0f); // in degrees float rotationSpeed = kRotationSpeed * rotationMultiplier * Time.fixedDeltaTime; float rotationLerpPercentage = Mathf.Clamp(rotationSpeed / minDeltaAngle, 0.0f, 1.0f); rigidbody_.MoveRotation(Quaternion.Lerp(this.transform.rotation, minRotation, rotationLerpPercentage)); }
public void Generate() { existance = (Time.time - createdTime) / lifetime; if (existance <= 1f) { existanceEased = Easings.Interpolate(existance, easing); current = FlatFXState.Lerp(start, end, existanceEased); switch (type) { case FlatFXType.Explosion: GenerateExplosion(); break; case FlatFXType.Ripple: GenerateRipple(); break; case FlatFXType.Pop: GeneratePop(); break; case FlatFXType.Crosslight: GenerateCrosslight(); break; case FlatFXType.SunRays: GenerateSunRays(); break; } } }
private void Update() { if (animationType == AnimationType.Bounce) { BounceAnimation(); } else { RepeatSingleAnimation(); } if (up) { currentPosition = Vector3.LerpUnclamped(startPos, targetPos, Easings.Interpolate(value, wayUp)); } else { currentPosition = Vector3.LerpUnclamped(startPos, targetPos, Easings.Interpolate(value, wayDown)); } if (ownRectTransform != null) { ownRectTransform.anchoredPosition = currentPosition; } else { transform.position = currentPosition; } }
// Token: 0x06000040 RID: 64 RVA: 0x00002BF4 File Offset: 0x00000DF4 public static void Update(Graphics g) { Time.TickTime(); if (Program.GetAsyncKeyState(Keys.Escape) != 0) { MainGame.curQuitAlpha += 0.0216666679f; } else { MainGame.curQuitAlpha -= 0.0166666675f; } MainGame.curQuitAlpha = SamMath.Clamp(MainGame.curQuitAlpha, 0f, 1f); if (MainGame.curQuitAlpha > 0.2f) { float num = (MainGame.curQuitAlpha - 0.2f) / 0.8f; int num2 = (int)SamMath.Lerp(-15f, 10f, Easings.ExponentialEaseOut(num * 2f)); SizeF sizeF = g.MeasureString("Continue Holding ESC to evict goose", MainGame.showCurQuitFont, int.MaxValue); g.FillRectangle(Brushes.LightBlue, new Rectangle(5, num2 - 5, (int)sizeF.Width + 10, (int)sizeF.Height + 10)); g.FillRectangle(Brushes.LightPink, new Rectangle(5, num2 - 5, (int)SamMath.Lerp(0f, sizeF.Width + 10f, num), (int)sizeF.Height + 10)); SolidBrush solidBrush = new SolidBrush(Color.FromArgb(255, (int)(256f * MainGame.curQuitAlpha), (int)(256f * MainGame.curQuitAlpha), (int)(256f * MainGame.curQuitAlpha))); g.DrawString("Continue holding ESC to evict goose", MainGame.showCurQuitFont, solidBrush, 10f, (float)num2); solidBrush.Dispose(); } if (MainGame.curQuitAlpha > 0.99f) { Application.Exit(); } TheGoose.Tick(); TheGoose.Render(g); }
private IEnumerator MoveTo() { float lerp = 0.0f; Vector3 position = Constantes.VECTOR_THREE_ZERO; Vector3 startPosition = transform.localPosition; Vector3 finalPosition = m_target.transform.localPosition; finalPosition.z = startPosition.z; while (lerp < 1.0f) { lerp += Time.deltaTime; position = Vector3.Lerp(startPosition, finalPosition, Easings.QuadraticEaseOut(lerp)); position.x = Mathf.Clamp(position.x, 0.0f, 35.75f); position.y = Mathf.Clamp(position.y, 0.0f, 13.4f); transform.localPosition = position; yield return(null); } Game.lateUpdate += CustomLateUpdate; m_target.InitAction(); }
/// <summary> /// Updates the engine's progress /// </summary> /// <param name="deltaTime"></param> public void Update(double deltaTime) { if (!Initialized) { return; } var keyframes = LayerProperty.UntypedKeyframes.ToList(); Progress = Progress.Add(TimeSpan.FromMilliseconds(deltaTime)); // The current keyframe is the last keyframe before the current time CurrentKeyframe = keyframes.LastOrDefault(k => k.Position <= Progress); // The next keyframe is the first keyframe that's after the current time NextKeyframe = keyframes.FirstOrDefault(k => k.Position > Progress); if (CurrentKeyframe == null) { KeyframeProgress = 0; KeyframeProgressEased = 0; } else if (NextKeyframe == null) { KeyframeProgress = 1; KeyframeProgressEased = 1; } else { var timeDiff = NextKeyframe.Position - CurrentKeyframe.Position; KeyframeProgress = (float)((Progress - CurrentKeyframe.Position).TotalMilliseconds / timeDiff.TotalMilliseconds); KeyframeProgressEased = (float)Easings.Interpolate(KeyframeProgress, CurrentKeyframe.EasingFunction); } // LayerProperty determines what's next: reset, stop, continue }
void UpdateTween() { Vector2 bounds = _fontComp.Font.MeasureString(_fontComp.Content); float _width = bounds.X; float _height = bounds.Y; float startX = _camera.ScreenToWorldCoords(new Vector2(_graphicsDevice.Viewport.Width, 0)).X; float endX = _camera.ScreenToWorldCoords(new Vector2(_graphicsDevice.Viewport.Width / 2, 0)).X; startX += _width / 2; float startY = _camera.ScreenToWorldCoords(new Vector2(0, _graphicsDevice.Viewport.Height / 2)).Y; float endY = _camera.ScreenToWorldCoords(new Vector2(0, _graphicsDevice.Viewport.Height)).Y; endY += _height / 2; float masterAlpha = _elapsed / Constants.Animations.INTRO_READY_DURATION; if (masterAlpha < 0.5f) { float alpha = masterAlpha * 2; float beta = Easings.CubicEaseOut(alpha); float valX = MathHelper.Lerp(startX, endX, beta); _transformComp.SetPosition(valX, 0); } else { float alpha = (masterAlpha - 0.5f) * 2; float beta = Easings.BackEaseIn(alpha); float valY = MathHelper.Lerp(startY, endY, beta); _transformComp.SetPosition(0, valY); } }
private void FixedUpdate() { z += Time.fixedDeltaTime + z * .005f; sweepTimerX += Time.fixedDeltaTime; if (sweepTimerX >= tuneIntervalX) { sweepTimerX -= tuneIntervalX; oldProjectionX = projectionX; projectionX = oldProjectionX + Random.Range(-1.00f, 1.00f) * Vector3.Distance(currentPos / 20, Vector3.zero); tuneIntervalX = Random.Range(.2f, .3f); } sweepTimerY += Time.fixedDeltaTime; if (sweepTimerY >= tuneIntervalY) { sweepTimerY -= tuneIntervalY; oldProjectionY = projectionY; projectionY = oldProjectionY + Random.Range(-1.00f, 1.00f) * Vector3.Distance(currentPos / 20, Vector3.zero); tuneIntervalY = Random.Range(.2f, .3f); } lastPos = currentPos; currentPos.x = currentX; currentPos.y = currentY; currentPos.z = z; currentX = Mathf.Lerp(oldProjectionX, projectionX, Easings.SineEaseInOut(sweepTimerX / tuneIntervalX)); currentY = Mathf.Lerp(oldProjectionY, projectionY, Easings.SineEaseInOut(sweepTimerX / tuneIntervalY)); GameObject g = Instantiate(prefab, currentPos, Quaternion.identity); currentRot = Quaternion.LookRotation(currentPos - lastPos); g.transform.rotation = currentRot; }
private IEnumerator TransistionAnimation(Vector3 finalPosition) { var startPosition = _instance.transform.localPosition; var v = finalPosition - startPosition; yield return(new WaitForSeconds(0.3f)); var progress = 0f; // 0 - 1 while (progress < 1f) { progress += Time.deltaTime * (1f / 0.35f); var derp = Easings.QuadraticEaseOut(progress); _instance.transform.localPosition = startPosition + v * derp; derp = Easings.QuadraticEaseOut(progress); _instance.transform.localScale = Vector3.Lerp(Vector3.zero, _originalScale, derp); yield return(null); } _instance.transform.localScale = _originalScale; _instance.transform.localPosition = finalPosition; yield return(new WaitForSeconds(0.25f)); _calibration.HasCompletedAnimation = true; }
// Update is called once per frame void Update() { if (initialized && !done) { float timeSinceStarted = Time.time - timeInterpolationStarted; float percentageComplete = timeSinceStarted / interpolationDuration; transform.position = new Vector2(startPos.x + xOffset * Easings.Linear(percentageComplete), startPos.y + yOffset * Easings.QuadraticEaseInOut(percentageComplete)); if (percentageComplete < colliderActivateLimit) { collider.enabled = false; } else { collider.enabled = true; } if (percentageComplete >= 1f) { done = true; if (papaFire) { SpawnBabyFires(); } } } }
internal static Quaternion?GetLocalRotation(dynamic dynData, float time) { Quaternion?localRotation = null; IEnumerable <float> localRotRaw = ((List <object>)Trees.at(dynData, LOCALROTATION))?.Select(Convert.ToSingle); if (localRotRaw != null) { localRotation = Quaternion.Euler(localRotRaw.ElementAt(0), localRotRaw.ElementAt(1), localRotRaw.ElementAt(2)); } List <RotationData> localRotationData = Trees.at(dynData, "varLocalRotation"); if (localRotationData != null) { RotationData truncatedRotation = localRotationData .Where(n => n.time < time) .Where(n => n.time + n.duration > time) .LastOrDefault(); if (truncatedRotation != null) { return(Quaternion.Lerp(truncatedRotation.startRotation, truncatedRotation.endRotation, Easings.Interpolate((time - truncatedRotation.time) / truncatedRotation.duration, truncatedRotation.easing))); } } return(localRotation); }
internal static Quaternion?GetWorldRotation(dynamic dynData, float time) { Quaternion?worldRotation = null; dynamic rotation = Trees.at(dynData, ROTATION); if (rotation != null) { if (rotation is List <object> list) { IEnumerable <float> _rot = (list)?.Select(Convert.ToSingle); worldRotation = Quaternion.Euler(_rot.ElementAt(0), _rot.ElementAt(1), _rot.ElementAt(2)); } else { worldRotation = Quaternion.Euler(0, (float)rotation, 0); } } List <RotationData> rotationData = Trees.at(dynData, "varRotation"); if (rotationData != null) { RotationData truncatedRotation = rotationData .Where(n => n.time < time) .Where(n => n.time + n.duration > time) .LastOrDefault(); if (truncatedRotation != null) { return(Quaternion.Lerp(truncatedRotation.startRotation, truncatedRotation.endRotation, Easings.Interpolate((time - truncatedRotation.time) / truncatedRotation.duration, truncatedRotation.easing))); } } return(worldRotation); }
// Token: 0x06000020 RID: 32 RVA: 0x00002754 File Offset: 0x00000954 public static float BounceEaseInOut(float p) { if (p < 0.5f) { return(0.5f * Easings.BounceEaseIn(p * 2f)); } return(0.5f * Easings.BounceEaseOut(p * 2f - 1f) + 0.5f); }
public void AddEasing(string key, string expression) { if (Easings == null) { Easings = new Dictionary <string, string>(); } Easings.Add(key, expression); }
protected override void OnUpdateAnimation() { float val = MathHelper.Lerp(StartAlpha, EndAlpha, Easings.Interpolate(ClampedAlpha, EasingFunction)); Root.FindWidgetsByClass(ClassName).ForEach((Widget widget) => { widget.Alpha = val; }); }
private static Vector3 AddActivePosition(Vector3 original) { if (_activePositionData != null) { return(original + Vector3.Lerp(_activePositionData.startPosition, _activePositionData.endPosition, Easings.Interpolate((_trueTime - _activePositionData.time) / _activePositionData.duration, _activePositionData.easing)) * _noteLinesDistance); } return(original); }
// Update is called once per frame void Update() { switch (state) { case State.Squash: { float heightChange = 1 - squashedHeight; float height = squashScale.y; height -= heightChange * Time.deltaTime / squashDuration; if (height <= squashedHeight) { height = squashedHeight; state = State.SquashedStill; timer = 0f; } SetScale(height); break; } case State.SquashedStill: if (timer > remainSquashedDuration && recover) { timer = 0f; state = State.Recover; } timer += Time.deltaTime; break; case State.Recover: { SetScale(Easings.EaseOutElastic(squashedHeight, 1, timer / recoverDuration)); timer += Time.deltaTime; if (timer >= recoverDuration) { CancelSquash(); } break; } } if (state != State.Still) { transform.localScale = Vector3.Scale(baseScale, squashScale); Vector3 pivotPosition = basePosition - new Vector3(0, collision.bounds.extents.y, 0); Vector3 pivotOffset = basePosition - pivotPosition; pivotPosition = basePosition - new Vector3(0, collision.bounds.extents.y * baseScale.y, 0); transform.position = Vector3.Scale(pivotOffset, transform.localScale) + pivotPosition; } }
void Start() { // StartCoroutine(WaitCoroutine(2)); // StartCoroutine(UpdateCoroutine()); // StartCoroutine(AnimationTools.MultiTranslateCoroutine(this, 5, Easings.EasingFunctionDelegate(m_EasingFunction))); StartCoroutine(InOutActionCoroutine( () => { MDebug.Log("in"); }, () => { MDebug.Log("out"); }, AnimationTools.MultiTranslateCoroutine(this, 5, Easings.EasingFunctionDelegate(m_EasingFunction)) )); }
protected override void OnUpdateAnimation() { if (IsAlive && !Engine.GetEntities().Contains(Entity)) { Kill(); return; } VectorSpriteComponent vectorSpriteComp = Entity.GetComponent <VectorSpriteComponent>(); vectorSpriteComp.ChangeStretch(new Vector2(WarpWidth * Easings.QuinticEaseIn(ClampedAlpha), vectorSpriteComp.Stretch.Y)); }
// PRAGMA MARK - Static Public Interface public static void Shake(float percentage) { if (percentage < 0.0f || percentage > 1.0f) { Debug.LogWarning("?? What are you trying to do here?"); } float shakeDuration = kShakeMaxDuration * percentage; Instance.transform.Shake(kShakeMaxAmount * percentage, shakeDuration, returnToOriginalPosition: false); Instance.AnimateChromaticAberration(intensity: Easings.QuarticEaseIn(percentage) * kAberrationMaxAmount, duration: shakeDuration); }
protected override void OnUpdateAnimation() { if (!Engine.GetEntities().Contains(Entity) && IsAlive) { Kill(); return; } TransformComponent transformComp = Entity.GetComponent <TransformComponent>(); transformComp.SetScale(MathHelper.Lerp(StartScale, EndScale, Easings.Interpolate(ClampedAlpha, EasingFunction))); }
private Int32 GetScreenOffset() { if (State == UIPanelState.Opening) { return(Width - (Int32)(Width * Easings.EaseOutBounce(TransitionPosition))); } if (State == UIPanelState.Closing) { return((Int32)(Width * Easings.EaseInSin(1.0f - TransitionPosition))); } return(0); }
private void Update() { float beat = CurrentBeatCount() - startBeat_ - beatOffset_; bool visible = (int)(beat / beatCountSwitch_) % 2 == 0; Vector3 scale = Vector3.one * Mathf.Lerp(1.0f, 1.03f, Easings.QuarticEaseIn(Mathf.Repeat(beat, length: 1.0f))); visibleContainer_.transform.localScale = scale; invisibleContainer_.transform.localScale = scale; SetVisible(visible); }
public void ApplyGravity() { fallingT += (Time.deltaTime); var percentageTo100 = Mathf.Lerp(0, 1, (fallingT)); var easedPercentage = Easings.QuinticEaseOut(percentageTo100); recalculatedFallSpeed = easedPercentage * fallSpeedInPixels; //Debug.Log(fallingT + " - " + percentageTo100 + " -- " + easedPercentage + " - " + recalculatedFallSpeed); MoveVertical(-1 * (recalculatedFallSpeed)); }
private IEnumerator PanelAnimationOutBack(RectTransform panel) { //panelBG.SetActive(true); float timer = 0f; while (timer < 1f) { timer += Time.deltaTime; //this code will run for 1s exact panel.localScale = Vector3.one * Mathf.LerpUnclamped(0.5f, 0f, Easings.QuadraticEaseOut(timer)); yield return(null); } }
/// <summary> /// Animates a Scroll Indicator /// </summary> /// <param name="startValue"></param> /// <param name="endValue"></param> /// <param name="verticalScrollIndicator"></param> /// <param name="lerpDuration"></param> /// <param name="onDone">Method to execute after it's done animating.</param> /// <returns></returns> public static IEnumerator ScrollIndicatorAnimator(float startValue, float endValue, VerticalScrollIndicator verticalScrollIndicator, float lerpDuration = 0.3f, Action onDone = null) { float timeElapsed = 0f; while (timeElapsed < lerpDuration) { verticalScrollIndicator.progress = Mathf.Lerp(startValue, endValue, Easings.EaseOutCubic(timeElapsed / lerpDuration)); timeElapsed += Time.deltaTime; yield return(null); } verticalScrollIndicator.progress = endValue; onDone?.Invoke(); }
void Update() { if (roll) { float timeSinceStarted = Time.time - timeInterpolationStarted; float percentageComplete = timeSinceStarted / interpolationDuration; transform.position = new Vector2(startPos.x + xOffset * Easings.QuadraticEaseOut(percentageComplete), startPos.y + yOffset * Easings.BounceEaseOut(percentageComplete)); if (percentageComplete >= 1f) { Stop(); } } }
public override void PreProcess(SKCanvas canvas, SKRect renderBounds, SKPaint paint) { // Progress moves from 0 to 2 bring that back to a value moving from 0 to 1 to 0 float progress = _progress; if (progress > 1) { progress = 2 - progress; } float alphaMultiplier; if (_progress <= 1f) { if (Properties.BrightenTransitionMode.CurrentValue == StrobeTransitionMode.Linear) { alphaMultiplier = progress; } else if (Properties.BrightenTransitionMode.CurrentValue == StrobeTransitionMode.Eased) { alphaMultiplier = (float)Easings.BounceEaseInOut(progress); } else { alphaMultiplier = MathF.Round(progress, 0); } } else { if (Properties.DimTransitionMode.CurrentValue == StrobeTransitionMode.Linear) { alphaMultiplier = progress; } else if (Properties.DimTransitionMode.CurrentValue == StrobeTransitionMode.Eased) { alphaMultiplier = (float)Easings.BounceEaseInOut(progress); } else { alphaMultiplier = MathF.Round(progress, 0); } } if (Properties.Inverted == true) { alphaMultiplier = 1 - alphaMultiplier; } paint.ColorF = paint.ColorF.WithAlpha(paint.ColorF.Alpha * alphaMultiplier); }
private IEnumerator PanelAnimationInFront(RectTransform panel, GameObject panelobject) { yield return(new WaitForSeconds(0.5f)); panelobject.SetActive(true); float timer = 0f; while (timer < 1f) { timer += Time.deltaTime; //this code will run for 1s exact panel.localScale = Vector3.one * Mathf.LerpUnclamped(2.0f, 0.5f, Easings.QuadraticEaseIn(timer)); yield return(null); } }