void Update() { if (isFadeEnd) { return; } time += Time.deltaTime; float alpha = 1.0f; if (fadeType == FadeType.FADEIN) { alpha = easing.CubicIn(easing.DelayTime(time, 0.0f, takeTime), 1.0f, 0.0f); } else if (fadeType == FadeType.FADEOUT) { alpha = easing.CubicIn(easing.DelayTime(time, 0.0f, takeTime), 0.0f, 1.0f); } GetComponent <Image>().color = new Color(fadeColor.r, fadeColor.g, fadeColor.b, alpha); if (time >= takeTime) { isFadeEnd = true; } }
private void Moving() { if (!isMove) { return; } moveTime += Time.deltaTime; float posY; if (moveTime < 0.5f) { posY = easing.CubicOut(easing.DelayTime(moveTime, 0.0f, 0.5f), originPosY, originPosY + jumpSpeed); } else { posY = easing.CubicIn(easing.DelayTime(moveTime, 0.5f, 0.5f), originPosY + jumpSpeed, originPosY); } transform.localPosition = new Vector3( transform.localPosition.x, posY, transform.localPosition.z); if (moveTime >= 1.0f) { moveTime = 0.0f; isMove = false; } }
IEnumerator ShowRoutine() { Vector2 size = container.sizeDelta; yield return(Tween.StartRoutine(0.3f, (float progress) => { container.sizeDelta = new Vector2(size.x, size.y * Easing.CubicIn(progress)); })); }
public void Shake() { tween.Start(0.5f, (float progress) => { float amount = Mathf.Lerp(1, 0, Easing.CubicIn(progress)); float angle = Random.value * 360; Vector2 offset = MathUtils.PolarToCartesian(angle, amount * 20); camera.transform.localPosition = offset; }); }
void OnFailTask() { SoundManager.instance.Play(wrongSound); cameraHelper.Shake(); tween.Start(0.5f, (float progress) => { float amount = Mathf.Lerp(1, 0, Easing.CubicIn(progress)); redOverlay.color = new Color(1, 0, 0, amount); }); }
IEnumerator ShowRoutine() { float width = bubble.sizeDelta.x; yield return(Tween.StartRoutine(0.3f, (float progress) => { float height = 30 * Easing.CubicIn(progress); bubble.sizeDelta = new Vector2(width, height); })); }
public void Refresh() { value1 = slider1.value; value2 = slider2.value; knob1.color = value1 == 1 ? Color.white : mintColor; knob2.color = value2 == 1 ? Color.white : mintColor; photo.GetComponent <RectTransform>().eulerAngles = Vector3.forward * (1 - value1) * 30; photo.color = Color.Lerp(Color.grey, Color.white, Easing.CubicIn(value2)); submitButton.interactable = AreValuesCorrect(); }
IEnumerator SquishRoutine() { float t = 0; float progress, scale; while (t < DURATION) { t += Time.deltaTime; progress = Easing.CubicIn(t / DURATION); scale = 1 + (1 - progress) / 2; transform.localScale = new Vector3(1 / scale, scale); yield return(null); } squishRoutine = null; }
public void CubicIn() { Utils.AreEqual( 0f, Easing.CubicIn(0f) ); Utils.AreEqual( 1f, Easing.CubicIn(1f) ); Utils.AreEqual( 0.125f, Easing.CubicIn(0.5f) ); }
IEnumerator RefreshRoutine() { refreshText.text = "Loading..."; refresh.GetComponent <Button>().interactable = false; Vector2 refreshSize = refresh.sizeDelta; yield return(Tween.StartRoutine(0.2f, (float progress) => { float height = Mathf.Lerp(refreshSize.y, 60, Easing.CubicIn(progress)); refresh.sizeDelta = new Vector2(refreshSize.x, height); })); yield return(new WaitForSeconds(0.6f)); yield return(Tween.StartRoutine(0.2f, (float progress) => { float height = Mathf.Lerp(60, 0, Easing.CubicOut(progress)); refresh.sizeDelta = new Vector2(refreshSize.x, height); })); phone.ResetCountdown(); int count = Random.Range(3, 6); gameData.postsLeft = count; for (int i = 0; i < count; i++) { Instantiate(postPrefab, feed).transform.SetSiblingIndex(0); SoundManager.instance.Play(postSound); if (feed.transform.childCount > 10) { Destroy(feed.transform.GetChild(10).gameObject); } yield return(new WaitForSeconds(0.1f)); } while (gameData.postsLeft > 0) { yield return(null); } isRefreshing = false; refreshText.text = "See More"; refresh.GetComponent <Button>().interactable = true; yield return(Tween.StartRoutine(0.2f, (float progress) => { float height = Mathf.Lerp(0, 30, Easing.CubicIn(progress)); refresh.sizeDelta = new Vector2(refreshSize.x, height); })); }
IEnumerator StartRoutine() { hud.anchoredPosition = Vector2.up * 200; blackOverlay.enabled = false; titleScreen.SetActive(true); while (!Input.GetMouseButton(0)) { yield return(null); } yield return(FadeBlackInRoutine()); titleScreen.SetActive(false); yield return(FadeTextRoutine("I like staying connected.\nIt keeps me happy.", 3)); yield return(Tween.StartRoutine(0.3f, (float progress) => { hud.anchoredPosition = Vector2.up * Mathf.Lerp(200, 0, Easing.CubicIn(progress)); })); yield return(FadeBlackOutRoutine()); blackOverlay.enabled = false; StartCoroutine(ProgressRoutine()); }
private void Move() { float xx = (endX - startX) * time / easingTime; float yy = 0.0f; switch (type) { case EasingType.Constant: yy = endY; break; case EasingType.QuadIn: yy = Easing.QuadIn(time, easingTime, startY, endY); break; case EasingType.QuadOut: yy = Easing.QuadOut(time, easingTime, startY, endY); break; case EasingType.QuadInOut: yy = Easing.QuadInOut(time, easingTime, startY, endY); break; case EasingType.CubicIn: yy = Easing.CubicIn(time, easingTime, startY, endY); break; case EasingType.CubicOut: yy = Easing.CubicOut(time, easingTime, startY, endY); break; case EasingType.CubicInOut: yy = Easing.CubicInOut(time, easingTime, startY, endY); break; case EasingType.QuartIn: yy = Easing.QuartIn(time, easingTime, startY, endY); break; case EasingType.QuartOut: yy = Easing.QuartOut(time, easingTime, startY, endY); break; case EasingType.QuartInOut: yy = Easing.QuartInOut(time, easingTime, startY, endY); break; case EasingType.QuintIn: yy = Easing.QuintIn(time, easingTime, startY, endY); break; case EasingType.QuintOut: yy = Easing.QuintOut(time, easingTime, startY, endY); break; case EasingType.QuintInOut: yy = Easing.QuintInOut(time, easingTime, startY, endY); break; case EasingType.SineIn: yy = Easing.SineIn(time, easingTime, startY, endY); break; case EasingType.SineOut: yy = Easing.SineOut(time, easingTime, startY, endY); break; case EasingType.SineInOut: yy = Easing.SineInOut(time, easingTime, startY, endY); break; case EasingType.ExpIn: yy = Easing.ExpIn(time, easingTime, startY, endY); break; case EasingType.ExpOut: yy = Easing.ExpOut(time, easingTime, startY, endY); break; case EasingType.ExpInOut: yy = Easing.ExpInOut(time, easingTime, startY, endY); break; case EasingType.CircIn: yy = Easing.CircIn(time, easingTime, startY, endY); break; case EasingType.CircOut: yy = Easing.CircOut(time, easingTime, startY, endY); break; case EasingType.CircInOut: yy = Easing.CircInOut(time, easingTime, startY, endY); break; case EasingType.ElasticIn: yy = Easing.ElasticIn(time, easingTime, startY, endY); break; case EasingType.ElasticOut: yy = Easing.ElasticOut(time, easingTime, startY, endY); break; case EasingType.ElasticInOut: yy = Easing.ElasticInOut(time, easingTime, startY, endY); break; case EasingType.BackIn: yy = Easing.BackIn(time, easingTime, startY, endY, 1.7f); break; case EasingType.BackOut: yy = Easing.BackOut(time, easingTime, startY, endY, 1.7f); break; case EasingType.BackInOut: yy = Easing.BackInOut(time, easingTime, startY, endY, 1.7f); break; case EasingType.BounceIn: yy = Easing.BounceIn(time, easingTime, startY, endY); break; case EasingType.BounceOut: yy = Easing.BounceOut(time, easingTime, startY, endY); break; case EasingType.BounceInOut: yy = Easing.BounceInOut(time, easingTime, startY, endY); break; case EasingType.Linear: yy = Easing.Linear(time, easingTime, startY, endY); break; } if (float.IsNaN(yy)) { yy = 1; } ball.transform.position = new Vector3(startX + xx, yy, 0); }
IEnumerator ProgressRoutine() { taskPhoto.gameObject.SetActive(true); yield return(Tween.StartRoutine(0.5f, (float progress) => { float x = Mathf.Lerp(1000, 0, Easing.CubicIn(progress)); taskPhoto.anchoredPosition = new Vector2(x, TASK_HEIGHT); })); while (gameData.score < 3) { yield return(null); } taskFeed.gameObject.SetActive(true); yield return(Tween.StartRoutine(0.5f, (float progress) => { float x = Mathf.Lerp(1000, 150, Easing.CubicIn(progress)); taskFeed.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(0, -150, Easing.CubicIn(progress)); taskPhoto.anchoredPosition = new Vector2(x, TASK_HEIGHT); })); while (gameData.score < 10) { yield return(null); } taskCall.gameObject.SetActive(true); yield return(Tween.StartRoutine(0.5f, (float progress) => { float x = Mathf.Lerp(1000, 250, Easing.CubicIn(progress)); taskCall.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(150, 0, Easing.CubicIn(progress)); taskFeed.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(-150, -250, Easing.CubicIn(progress)); taskPhoto.anchoredPosition = new Vector2(x, TASK_HEIGHT); })); while (gameData.score < 30) { yield return(null); } taskText.gameObject.SetActive(true); yield return(Tween.StartRoutine(0.5f, (float progress) => { float x = Mathf.Lerp(1000, 300, Easing.CubicIn(progress)); taskText.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(250, 100, Easing.CubicIn(progress)); taskCall.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(0, -100, Easing.CubicIn(progress)); taskFeed.anchoredPosition = new Vector2(x, TASK_HEIGHT); x = Mathf.Lerp(-250, -300, Easing.CubicIn(progress)); taskPhoto.anchoredPosition = new Vector2(x, TASK_HEIGHT); })); while (gameData.score < 60) { yield return(null); } gameData.onFire = true; taskPhoto.GetComponent <Phone>().Burn(); yield return(new WaitForSeconds(1 + Random.value * 3)); taskFeed.GetComponent <Phone>().Burn(); yield return(new WaitForSeconds(1 + Random.value * 3)); taskCall.GetComponent <Phone>().Burn(); yield return(new WaitForSeconds(1 + Random.value * 3)); taskText.GetComponent <Phone>().Burn(); yield return(new WaitForSeconds(8)); gameData.ending = true; gameData.happiness.Finish(); yield return(FadeBlackInRoutine()); endingImage.enabled = true; endingImage.sprite = endingSprites[0]; yield return(FadeTextRoutine("This is too much for me...", 2)); yield return(FadeBlackOutRoutine()); yield return(new WaitForSeconds(4)); yield return(FadeBlackInRoutine()); endingImage.sprite = endingSprites[1]; yield return(FadeTextRoutine("I need a change of pace.", 2)); yield return(FadeBlackOutRoutine()); gameData.happiness.Elapse(-30); yield return(new WaitForSeconds(4)); yield return(FadeBlackInRoutine()); endingImage.sprite = endingSprites[2]; yield return(FadeBlackOutRoutine()); gameData.happiness.Elapse(-30); yield return(new WaitForSeconds(4)); yield return(FadeBlackInRoutine()); endingImage.sprite = endingSprites[3]; yield return(FadeBlackOutRoutine()); gameData.happiness.Elapse(-40); yield return(new WaitForSeconds(4)); yield return(FadeBlackInRoutine()); yield return(FadeTextRoutine("Thanks for playing!", 8)); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); }
IEnumerator IntroRoutine() { float t = 0; float scale = 0; titleWhatThe.localScale = Vector2.zero; titleFiretruck.localScale = Vector2.zero; worldUI.SetActive(false); yield return(new WaitForSeconds(0.3f)); SoundManager.Play(thudSound); while (t < 0.5f) { scale = Easing.ElasticOut(t * 2); titleWhatThe.localScale = new Vector2(scale, scale); t += Time.deltaTime; yield return(null); } titleWhatThe.localScale = new Vector2(1, 1); SoundManager.Play(thudSound); t = 0; while (t < 0.5f) { scale = Easing.ElasticOut(t * 2); titleFiretruck.localScale = new Vector2(scale, scale); t += Time.deltaTime; yield return(null); } titleFiretruck.localScale = new Vector2(1, 1); RectTransform worldTransform = worldUI.GetComponent <RectTransform>(); worldTransform.anchoredPosition = Vector2.down * 100; worldUI.SetActive(true); t = 0; while (t < 0.5f) { float y = (1 - Easing.CubicIn(t * 2)) * 100; worldTransform.anchoredPosition = Vector2.down * y; t += Time.deltaTime; yield return(null); } worldTransform.anchoredPosition = Vector2.zero; while (Input.GetAxisRaw("PlayerHorizontal") == 0 && Input.GetAxisRaw("PlayerVertical") == 0) { yield return(null); } yield return(new WaitForSeconds(0.3f)); prompt.text = "Water - <color=\"#1E8AD4\">Arrow Keys</color>"; while (Input.GetAxisRaw("WaterHorizontal") == 0 && Input.GetAxisRaw("WaterVertical") == 0) { yield return(null); } yield return(new WaitForSeconds(0.3f)); prompt.text = "Starting mission!"; yield return(new WaitForSeconds(2)); SceneManager.LoadScene("Instructions"); }
public System.Func <float, float> GetEaseAction(EzEaseType type) { if (type == EzEaseType.SineIn) { return((v) => Easing.SineIn(v)); } else if (type == EzEaseType.SineOut) { return((v) => Easing.SineOut(v)); } else if (type == EzEaseType.SineInOut) { return((v) => Easing.SineInOut(v)); } else if (type == EzEaseType.QuadIn) { return((v) => Easing.QuadIn(v)); } else if (type == EzEaseType.QuadOut) { return((v) => Easing.QuadOut(v)); } else if (type == EzEaseType.QuadInOut) { return((v) => Easing.QuadInOut(v)); } else if (type == EzEaseType.CubicIn) { return((v) => Easing.CubicIn(v)); } else if (type == EzEaseType.CubicOut) { return((v) => Easing.CubicOut(v)); } else if (type == EzEaseType.CubicInOut) { return((v) => Easing.CubicInOut(v)); } else if (type == EzEaseType.QuartIn) { return((v) => Easing.QuartIn(v)); } else if (type == EzEaseType.QuartOut) { return((v) => Easing.QuartOut(v)); } else if (type == EzEaseType.QuartInOut) { return((v) => Easing.QuartInOut(v)); } else if (type == EzEaseType.ExpIn) { return((v) => Easing.ExpIn(v)); } else if (type == EzEaseType.ExpOut) { return((v) => Easing.ExpOut(v)); } else if (type == EzEaseType.ExpInOut) { return((v) => Easing.ExpInOut(v)); } else if (type == EzEaseType.CircIn) { return((v) => Easing.CircIn(v)); } else if (type == EzEaseType.CircOut) { return((v) => Easing.CircOut(v)); } else if (type == EzEaseType.CircInOut) { return((v) => Easing.CircInOut(v)); } else if (type == EzEaseType.ElasticIn) { return((v) => Easing.ElasticIn(v)); } else if (type == EzEaseType.ElasticOut) { return((v) => Easing.ElasticOut(v)); } else if (type == EzEaseType.ElasticInOut) { return((v) => Easing.ElasticInOut(v)); } else if (type == EzEaseType.BackIn) { return((v) => Easing.BackIn(v)); } else if (type == EzEaseType.BackOut) { return((v) => Easing.BackOut(v)); } else if (type == EzEaseType.BackInOut) { return((v) => Easing.BackInOut(v)); } else if (type == EzEaseType.BounceIn) { return((v) => Easing.BounceIn(v)); } else if (type == EzEaseType.BounceOut) { return((v) => Easing.BounceOut(v)); } else if (type == EzEaseType.BounceInOut) { return((v) => Easing.BounceInOut(v)); } else { return((v) => Easing.Linear(v)); } }