/// <summary> /// Return value based on curve from Mathfx class. /// </summary> /// <returns>The value.</returns> /// <param name="animationCurve">Animation curve.</param> /// <param name="start">Start.</param> /// <param name="end">End.</param> /// <param name="t">T.</param> public static float CurvedValue(AnimationCurveEnum animationCurve, float start, float end, float t) { switch (animationCurve) { case AnimationCurveEnum.Hermite: return(Mathfx.Hermite(start, end, t)); case AnimationCurveEnum.Sinerp: return(Mathfx.Sinerp(start, end, t)); case AnimationCurveEnum.Coserp: return(Mathfx.Coserp(start, end, t)); case AnimationCurveEnum.Berp: return(Mathfx.Berp(start, end, t)); case AnimationCurveEnum.Bounce: return(start + ((end - start) * Mathfx.Bounce(t))); case AnimationCurveEnum.Lerp: return(Mathfx.Lerp(start, end, t)); case AnimationCurveEnum.Clerp: return(Mathfx.Clerp(start, end, t)); default: return(0); } }
private float AnimationCurveCompletionPerc(float origPercentage) { switch (AnimationCurve) { case AnimationCurves.Linear: { return(Mathfx.Lerp(0, 1, origPercentage)); } case AnimationCurves.Elastic: { return(Mathfx.Berp(0, 1, origPercentage)); } case AnimationCurves.Bounce: { return(Mathfx.Bounce(origPercentage)); } case AnimationCurves.EaseInOut: default: { return(Mathfx.Hermite(0, 1, origPercentage)); } } }
void Update() { if (time < 1) { transform.localScale = Vector3.one * Mathfx.Berp(0f, 1f, time); time += Time.deltaTime; } }
public static Vector3 Berp(Vector3 start, Vector3 end, float value) { return(new Vector3( Mathfx.Berp(start.x, end.x, value), Mathfx.Berp(start.y, end.y, value), Mathfx.Berp(start.z, end.z, value) )); }
// Update is called once per frame void Update() { countDown -= Time.deltaTime * fallSpeed; transform.position = Mathfx.Berp(transform.position, endPos, Time.deltaTime * fallSpeed); if (countDown <= 0) { FindObjectOfType <LevelManager>().LoadLevel("Level Select"); } }
public IEnumerator AnimatePop() { var time = 0f; while (time < PopDuration) { time += Time.deltaTime; transform.localScale = Vector3.one * Mathfx.Berp(0, 1, time / PopDuration); yield return(null); } }
private IEnumerator Grow() { Vector3 easeStart = transform.localScale; Vector3 easeGoal = easeStart * (1.0f + growAmount); float easeSpeed = growDuration / 100.0f; for (float perc = 0; perc <= 1f; perc += 0.01f) { transform.localScale = Mathfx.Berp(easeStart, easeGoal, perc); yield return(new WaitForSeconds(easeSpeed)); } }
private float Evaluate(float timer, MoveType type, bool moveIn) { switch (type) { default: return(timer); case MoveType.Lerp: return(timer); case MoveType.Boing: return(Mathfx.Berp(0f, 1f, timer)); case MoveType.Ease: return(moveIn ? Mathfx.Sinerp(0f, 1f, timer) : Mathfx.Coserp(0f, 1f, timer)); } }
// Token: 0x06000980 RID: 2432 RVA: 0x0003BBBC File Offset: 0x00039DBC public override void Animate() { if (this._timer < this._scaleTime) { this._scale = Mathfx.Berp(0.3f, 1f, this._timer / this._scaleTime * 2f); } else if (this._timer < this._scaleTime + this._moveTime) { this._rect.y = Mathf.Lerp(this._rect.y, 0f, 10f * Time.deltaTime); this._alpha = Mathf.Lerp(this._alpha, 0f, 10f * Time.deltaTime); } this._timer += Time.deltaTime; }
private void Update() { // todo: more robust weapon sway var mdelta = new Vector3(-Input.GetAxis("Mouse X"), -Input.GetAxisRaw("Mouse Y"), 0) / 35f; _swayPosition += mdelta * Time.deltaTime; _swayPosition = Vector3.ClampMagnitude(_swayPosition, .06f); _swayPosition = Mathfx.Berp(_swayPosition, Vector3.zero, Time.deltaTime); _kick = Vector3.MoveTowards(_kick, Vector3.zero, 10f * Time.deltaTime); _animator.transform.localPosition = _originalPosition + _swayPosition + new Vector3(0, 0, _kick.z); _animator.transform.localEulerAngles = _originalRotation + new Vector3(_kick.x, 0, 0); }
// Token: 0x0600097B RID: 2427 RVA: 0x0003BAC4 File Offset: 0x00039CC4 public override void Animate() { if (this._timer < this._moveTime) { this._rect.y = Mathfx.Berp(0f, this._height, this._timer / this._moveTime); this._alpha = Mathf.Lerp(this._alpha, 1f, 8f * Time.deltaTime); } else if (this._timer > this._moveTime + this._scaleTime && this._timer < this._moveTime + this._stayTime + this._scaleTime) { this._scale = Mathf.Lerp(this._scale, 0.5f, 15f * Time.deltaTime); this._alpha = Mathf.Lerp(this._alpha, 0.2f, 10f * Time.deltaTime); } this._timer += Time.deltaTime; }
public virtual void RecTransformUpdate() { if (_rectTf == null) { return; } if (_animate) { _elapsedAnimTime += Time.deltaTime; if (!_finishedDelay && _elapsedAnimTime > _delayTime) { _elapsedAnimTime = 0; _finishedDelay = true; } if (_elapsedAnimTime >= _animationTime) { _rectTf.anchoredPosition3D = _endPos; _animate = false; return; } float time = _elapsedAnimTime / _animationTime; if (_evaluationType == AnimationFunction.EASE_IN) { _rectTf.anchoredPosition3D = Mathfx.Coserp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.EASE_OUT) { _rectTf.anchoredPosition3D = Mathfx.Sinerp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.EASE_IN_OUT) { _rectTf.anchoredPosition3D = Mathfx.Hermite(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.BOING) { _rectTf.anchoredPosition3D = Mathfx.Berp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.CUSTOM_CURVE) { _rectTf.anchoredPosition3D = Vector3.Lerp(_initialPos, _endPos, _customCurve.Evaluate(time)); } } }
IEnumerator SpawnPortal() { PortalObj.SetActive(true); float start = Time.time; float elapsedTime = Time.time - start; PortalController controller = PortalObj.GetComponent <PortalController>(); while (elapsedTime < OpenTime) { elapsedTime = Time.time - start; float timeScalar = elapsedTime / OpenTime; Vector3 portalScale = Mathfx.Berp(Vector3.one * 0.01f, PortalSize, timeScalar);; //controller.Portal.transform.localScale = portalScale; controller.PortalOpeningSize = portalScale; yield return(new WaitForEndOfFrame()); } this.gameObject.SetActive(false); Travelling = false; }
// Token: 0x06001CDE RID: 7390 RVA: 0x00091594 File Offset: 0x0008F794 public static float Ease(float t, EaseType easeType) { switch (easeType) { case EaseType.In: return(Mathf.Lerp(0f, 1f, 1f - Mathf.Cos(t * 3.14159274f * 0.5f))); case EaseType.Out: return(Mathf.Lerp(0f, 1f, Mathf.Sin(t * 3.14159274f * 0.5f))); case EaseType.InOut: return(Mathf.SmoothStep(0f, 1f, t)); case EaseType.Berp: return(Mathfx.Berp(0f, 1f, t)); default: return(t); } }
// Token: 0x06000933 RID: 2355 RVA: 0x0003A6EC File Offset: 0x000388EC private IEnumerator StartDragZoom(float time, float startZoom, float endZoom, float startAlpha, float endAlpha) { this._isZooming = true; Vector2 startPivot = new Vector2(this._draggedControlRect.xMin + 32f, this._draggedControlRect.yMin + 32f); float timer = 0f; while (timer < time) { this._alphaValue = Mathf.Lerp(startAlpha, endAlpha, timer / time); this._zoomMultiplier = Mathfx.Berp(startZoom, endZoom, timer / time); this._dragScalePivot = Vector2.Lerp(startPivot, Event.current.mousePosition, timer / time); timer += Time.deltaTime; yield return(new WaitForEndOfFrame()); } this._dragScalePivot = Event.current.mousePosition; this._alphaValue = endAlpha; this._zoomMultiplier = endZoom; this._isZooming = false; yield break; }
private IEnumerator SpawnPortal() { PortalObj.SetActive(true); var start = Time.time; var elapsedTime = Time.time - start; var controller = PortalObj.GetComponent <PortalController>(); while (elapsedTime < OpenTime) { elapsedTime = Time.time - start; var timeScalar = elapsedTime / OpenTime; var portalScale = Mathfx.Berp(Vector3.one * 0.01f, PortalSize, timeScalar); ; //controller.Portal.transform.localScale = portalScale; controller.PortalOpeningSize = portalScale; yield return(WaitCache.Frame); } gameObject.SetActive(false); Travelling = false; }
private float DoLerp() { switch (this._currentLerpType) { case LerpType.Lerp: return(Mathfx.Lerp(this.From, this.To, this.LerpZeroToOne)); case LerpType.Hermite: return(Mathfx.Lerp(this.From, this.To, this.LerpZeroToOne)); case LerpType.Sinerp: return(Mathfx.Sinerp(this.From, this.To, this.LerpZeroToOne)); case LerpType.Coserp: return(Mathfx.Coserp(this.From, this.To, this.LerpZeroToOne)); case LerpType.Berp: return(Mathfx.Berp(this.From, this.To, this.LerpZeroToOne)); case LerpType.Smoothstep: return(Mathfx.SmoothStep(this.From, this.To, this.LerpZeroToOne)); case LerpType.Clerp: return(Mathfx.Clerp(this.From, this.To, this.LerpZeroToOne)); default: throw new ArgumentOutOfRangeException(); } }
private float ApplyEasing(float erpPos) { switch (EaseType) { case EaseType.In: return(Mathfx.Coserp(0, 1, erpPos)); case EaseType.Out: return(Mathfx.Sinerp(0, 1, erpPos)); case EaseType.InOut: return(Mathfx.Hermite(0, 1, erpPos)); case EaseType.Boing: return(Mathfx.Berp(0, 1, erpPos, .5f)); case EaseType.Bounce: return(Mathfx.Bounce(erpPos)); } return(erpPos); }
private void moveNotificationByYOffset(GameObject notification, float yToMoveTotal, float t) { Vector3 currPos = notification.GetComponent <RectTransform>().anchoredPosition; float startPositionY = firstNotificationLoc.y + startYOffset; notification.GetComponent <RectTransform>().anchoredPosition = new Vector3(currPos.x, Mathfx.Berp(startPositionY, startPositionY + yToMoveTotal, t), currPos.z); }
public virtual void TransformUpdate() { if (_animate) { if (_unscaledDeltaTime) { _elapsedAnimTime += Time.unscaledDeltaTime; } else { _elapsedAnimTime += Time.deltaTime; } if (!_finishedDelay) { if (_elapsedAnimTime > _delayTime) { _elapsedAnimTime = 0; _finishedDelay = true; } return; } if (_elapsedAnimTime >= _animationTime) { if (_loop) { _elapsedAnimTime = 0; _returning = !_returning; } else { transform.localPosition = _endPos; _animate = false; return; } } float time = _elapsedAnimTime / _animationTime; if (!_returning) { if (_evaluationType == AnimationFunction.EASE_IN) { transform.localPosition = Mathfx.Coserp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.EASE_OUT) { transform.localPosition = Mathfx.Sinerp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.EASE_IN_OUT) { transform.localPosition = Mathfx.Hermite(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.BOING) { transform.localPosition = Mathfx.Berp(_initialPos, _endPos, time); } else if (_evaluationType == AnimationFunction.CUSTOM_CURVE) { transform.localPosition = Vector3.Lerp(_initialPos, _endPos, _customCurve.Evaluate(time)); } } else { if (_evaluationType == AnimationFunction.EASE_IN) { transform.localPosition = Mathfx.Coserp(_endPos, _initialPos, time); } else if (_evaluationType == AnimationFunction.EASE_OUT) { transform.localPosition = Mathfx.Sinerp(_endPos, _initialPos, time); } else if (_evaluationType == AnimationFunction.EASE_IN_OUT) { transform.localPosition = Mathfx.Hermite(_endPos, _initialPos, time); } else if (_evaluationType == AnimationFunction.BOING) { transform.localPosition = Mathfx.Berp(_endPos, _initialPos, time); } else if (_evaluationType == AnimationFunction.CUSTOM_CURVE) { transform.localPosition = Vector3.Lerp(_endPos, _initialPos, _customCurve.Evaluate(time)); } } } }
void OnDisable() { time = 0; transform.localScale = Vector3.one * Mathfx.Berp(0f, 0f, time); //den här är för att säkerställa att skalan //resettas till 0 så att den inte poppar abrupt innan berp animationen initieras }