public IEnumerator RevealBlock(bool val) { float t = 0; float d = .15f; float a = val ? 1f : 0f; while (t < d) { t += Time.fixedDeltaTime; float p = Mathf.Clamp01(t / d); if (val) { alpha = a * EZEasings.SmoothStop3(p); s.color = new Color(color.r, color.g, color.b, alpha); } else { alpha = a - a * EZEasings.SmoothStart3(p); s.color = new Color(color.r, color.g, color.b, alpha); } yield return(new WaitForFixedUpdate()); } }
public IEnumerator ShowText(bool val) { float t = 0; float d = .25f; float a = 0; while (t < d) { t += Time.fixedDeltaTime; float p = Mathf.Clamp01(t / d); if (val) { a = start.a * EZEasings.SmoothStop3(p); } else { a = start.a - start.a * EZEasings.SmoothStart3(p); } current = new Color(start.r, start.g, start.b, a); GetComponent <TMP_Text>().color = current; yield return(new WaitForFixedUpdate()); } }
IEnumerator Explode() { float t = 0; float targetScale = 40; while (t < explodeDuration) { t += Time.fixedDeltaTime; target.transform.localScale = Vector3.one + Vector3.one * targetScale * EZEasings.SmoothStop3(t / explodeDuration); yield return(new WaitForFixedUpdate()); } }
IEnumerator ShowGrab() { float t = 0; float d = grabDuration; while (t < d) { float p = Mathf.Clamp01(t / d); t += Time.fixedDeltaTime; targetRadius = grabRadius + (jumpRadius - grabRadius) * (1 - EZEasings.SmoothStop3(p)); yield return(new WaitForFixedUpdate()); } }
IEnumerator Implode() { Vector3 startScale = target.transform.localScale; float t = 0; while (t < implodeDuration) { t += Time.fixedDeltaTime; target.transform.localScale = startScale - startScale * EZEasings.SmoothStop5(t / implodeDuration); yield return(new WaitForFixedUpdate()); } Destroy(target.transform.root.gameObject); }
IEnumerator Flash() { float d = flashDuration; float t = 0; while (t < d) { t += Time.fixedDeltaTime; float p = t / d; float alpha = (1 - EZEasings.SmoothStop3(p)) * flashColor.a; Color adjustedColor = new Color(flashColor.r, flashColor.g, flashColor.b, alpha); s.color = adjustedColor; yield return(new WaitForFixedUpdate()); } }
IEnumerator AnimateRing() { SpriteRenderer target = foreground; float time = 0; float targetRadius = targetMax - baseRadius; while (time < ringDuration) { time += Time.fixedDeltaTime; float t = time / ringDuration; float radius = 0; radius = baseRadius + targetRadius * EZEasings.SmoothStart3(t); target.transform.localScale = Vector3.one * radius; yield return(new WaitForFixedUpdate()); } }
IEnumerator AnimateMask() { SpriteRenderer target = background; float time = 0; float targetRadius = targetMax - baseRadius; while (time < maskDuration) { time += Time.fixedDeltaTime; float t = time / maskDuration; float radius = 0; radius = baseRadius + targetRadius * EZEasings.SmoothStart3(t) * 1.01f; target.transform.localScale = Vector3.one * radius; yield return(new WaitForFixedUpdate()); } Destroy(gameObject); }
IEnumerator FadeOut() { if (fadeDuration < threshold) { Destroy(gameObject); } float t = 0; while (t < fadeDuration) { t += Time.fixedDeltaTime; myColor = s.color; myColor.a = startAlpha * (1 - EZEasings.SmoothStart3(t / fadeDuration)); s.color = myColor; yield return(new WaitForFixedUpdate()); } Destroy(gameObject); }
// Update is called once per frame void Update() { mousePos = Input.mousePosition; if (Input.GetMouseButtonDown(0)) { startPos = mousePos; } if (Input.GetMouseButton(0)) { if (Input.mousePosition.y < Screen.height / 2) { // mouseDelta = (Vector2)Input.mousePosition - lastPosition; // lastPosition = Input.mousePosition; drag = mousePos - startPos; value += EZEasings.SmoothStart3(drag.x); } } }
IEnumerator AnimateCircle() { float t = 0; while (t < animationDuration) { t += Time.deltaTime; float percent = t / animationDuration; radius = maxRadius * EZEasings.SmoothStart3(percent); float alpha = alphaOverTime.Evaluate(percent); Color lineColor = GetComponent <LineRenderer>().material.color; lineColor.a = alpha; line.material.color = lineColor; line.startColor = lineColor; line.endColor = lineColor; yield return(new WaitForEndOfFrame()); } }
void SpawnCircle(Vector2 position) { Vector3 targetPos = position; targetPos.z = -1; CircleEffect f = Instantiate(circle); f.transform.position = targetPos; radiusDiff = maxRadius - minRadius; widthDiff = maxWidthPercent - minWidthPercent; timeDiff = maxTime - minTime; float circleRadius = minRadius + radiusDiff * EZEasings.SmoothStart3(percent); Debug.Log(radiusDiff * EZEasings.SmoothStart3(percent)); float lineWidth = minWidthPercent + widthDiff * EZEasings.SmoothStart3(percent); float duration = minTime + timeDiff * EZEasings.SmoothStart3(percent); f.TriggerCircle(circleRadius, lineWidth, myColor, duration, true); }
void UpdateColor(Vector2 offset) { float t = gradientIndexPct + (EZEasings.SmoothStart3(offset.x) * gradientAdjustmentRate * Time.deltaTime); if (useConstantFlow) { t += constantFlowRate * Time.deltaTime; } if (t < 0) { t = 1 - t; } else { t %= 1; } gradientIndexPct = t; bgColor = colorRange.Evaluate(t); s.color = bgColor; }
void AdjustRadiusAndWidth(float t) { radius = baseradius + spreadSpeed * EZEasings.SmoothStart2(t); lineWidth = radius * lineWidthPercent; }
float GetSmoothStepRange(AnimationParameter p) { return(p.start + (p.end - p.start) * EZEasings.SmoothStep3(percent)); }
public static float GetSmoothStop5Range(Property p, float t) { return(p.start + (p.end - p.start) * EZEasings.SmoothStop5(t)); }
public static float GetLinearRange(Property p, float t) { return(p.start + (p.end - p.start) * EZEasings.Linear(t)); }
public IEnumerator PlayMaskOut() { float t = 0; while (t < maskOutDuration) { t += Time.fixedDeltaTime; mask.transform.localScale = Vector3.zero + Vector3.one * baseScale * (1 - EZEasings.SmoothStart3(t / maskOutDuration)); yield return(new WaitForFixedUpdate()); } }
IEnumerator GameOver() { float t = 0; while (exploding) { if (t < explodeDuration) { // Debug.Log("growing"); t += Time.deltaTime; transform.localScale = Vector3.one + Vector3.one * targetScale * EZEasings.SmoothStart5(t / explodeDuration); yield return(new WaitForEndOfFrame()); } else { exploding = false; waiting = true; } } // wait at max scale t = 0; while (waiting) { if (t < waitDuration) { // Debug.Log("waiting"); t += Time.deltaTime; yield return(new WaitForEndOfFrame()); } else { waiting = false; imploding = true; } } Vector3 largeScale = transform.localScale; t = 0; while (imploding) { if (t < implodeDuration) { // Debug.Log("imploding"); t += Time.deltaTime; transform.localScale = largeScale - largeScale * EZEasings.SmoothStop5(t / implodeDuration); yield return(new WaitForEndOfFrame()); } else { transform.localScale = Vector3.zero; imploding = false; } } NewGameManager.GetInstance().ResetGame(); Destroy(gameObject); }