MyCoroutine GetFadeAnimation(Color startColor, Color endColor, float duration) { return(KKUtilities.FloatLerp(duration, (t) => { panel.color = Color.Lerp(startColor, endColor, t * t); })); }
protected override IEnumerator TutorialAnimation() { var wait = new WaitForSeconds(0.5f); while (true) { fingerRectTransform.anchoredPosition = startPoint.RectTransform.anchoredPosition; ChangeImage(FingerType.Up); fingerRectTransform.gameObject.SetActive(true); yield return(wait); ChangeImage(FingerType.Down); yield return(wait); var start = startPoint.RectTransform.anchoredPosition; var end = endPoint.RectTransform.anchoredPosition; var duration = KKUtilities.GetDuration(start, end, speed); yield return(KKUtilities.FloatLerp(duration, (t) => { end = endPoint.RectTransform.anchoredPosition; fingerRectTransform.anchoredPosition = Vector3.Lerp(start, end, t); }, false)); ChangeImage(FingerType.Up); yield return(wait); fingerRectTransform.gameObject.SetActive(false); } }
IEnumerator SkipMissionAnimation(MissionInfoViewer skipInfoViewer) { var missionManager = MyMissionManager.Instance; missionManager.SkipMission(skipInfoViewer.MissionData); AddInfoViewer(3); yield return(KKUtilities.FloatLerp(0.3f, (t) => { skipInfoViewer.transform.localScale = Vector3.Lerp(Vector3.one, Vector3.zero, Easing.InQuad(t)); })); infoViewerPool.ReturnInstance(skipInfoViewer.GetComponent <PoolMonoBehaviour>()); viewers.Remove(skipInfoViewer); for (int i = 0; i < viewers.Count; i++) { var viewer = viewers[i]; var rectTransform = viewer.transform as RectTransform; var startPos = rectTransform.anchoredPosition; var origin = new Vector2(-365.0f, 0.0f); var offset = new Vector2(365.0f, 0.0f); var targetPos = origin + (offset * i); this.FloatLerp(0.3f, (t) => { rectTransform.anchoredPosition = Vector2.Lerp(startPos, targetPos, Easing.OutQuad(t)); }); } yield return(new WaitForSeconds(0.3f)); skipMissionAnimating = false; }
void FitImage(int index) { index = Mathf.Clamp(index, 0, imageNum - 1); isChangeImage = index != currentSelectIndex; currentSelectIndex = index; if (fitCoroutine != null) { StopCoroutine(fitCoroutine); } float targetX = -screenWidth * index; float startX = rec.anchoredPosition.x; //何秒かけてtargetXにするかはtargetXまでの距離で判断する float duration = (Mathf.Abs(targetX - startX) / screenWidth) / fitSpeed; Vector2 currentPosition = rec.anchoredPosition; fitCoroutine = StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { currentPosition.x = Mathf.Lerp(startX, targetX, t * t); rec.anchoredPosition = currentPosition; }).OnCompleted(() => { fitCoroutine = null; pageControl.SetIndex(currentSelectIndex); })); }
IEnumerator VibrateCoroutine(float duration) { var manager = MyVibrationManager.Instance; yield return(KKUtilities.FloatLerp(duration, (_) => { manager.Vibrate(VibrationType.SelectionChange); })); }
MyCoroutine ChangeSelectMakerPosition(Vector2 targetPosition) { Vector2 startPosition = selectMakerRec.anchoredPosition; return(KKUtilities.FloatLerp(0.2f, (t) => { selectMakerRec.anchoredPosition = Vector2.Lerp(startPosition, targetPosition, t); }).OnCompleted(() => positionControlCoroutine = null)); }
IEnumerator CloseBookAnimation() { bookAnimator.Play("CloseBook"); yield return(new WaitForSeconds(1.5f)); var startPos = cameraTransform.position; var startRot = cameraTransform.rotation; yield return(KKUtilities.FloatLerp(1.0f, (t) => { var temp = Easing.InQuad(t); cameraTransform.SetPositionAndRotation( Vector3.Lerp(startPos, targetCameraTransform.position, temp), Quaternion.Lerp(startRot, targetCameraTransform.rotation, temp)); })); namingContainer.SetActive(true); while (true) { yield return(KKUtilities.WaitAction(okButton.onClick)); if (!string.IsNullOrEmpty(input.text)) { break; } } namingContainer.SetActive(false); textmesh.text = input.text; //1回転 var c = Camera.main.transform; yield return(KKUtilities.FloatLerp(0.5f, (t) => { c.AddLocalPositoinZ(-1.0f * Time.deltaTime); })); gameClearMessage.SetActive(true); reReadButton.gameObject.SetActive(true); gotoTitleButton.gameObject.SetActive(true); foreach (var p in particles) { p.Play(true); } while (true) { yield return(KKUtilities.FloatLerp(3.0f, (t) => { bookAnimator.transform.parent.SetRotationZ(Mathf.Lerp(0.0f, 360.0f, Easing.Linear(t))); })); } }
IEnumerator Animation() { while (true) { yield return(KKUtilities.FloatLerp(2.0f, (t) => { //baseImage.transform.localScale = Vector3.one * Mathf.LerpUnclamped(1.0f, 1.3f, baseImageScaleCurve.Evaluate(t)); markImage.transform.localScale = Vector3.one * Mathf.LerpUnclamped(1.0f, 1.5f, markImageScaleCurve.Evaluate(t)); baseImage.transform.SetLocalRotationZ(Mathf.LerpUnclamped(0.0f, 30.0f, markImageRotCurve.Evaluate(t))); })); } }
//void Start() //{ // Sequence sequence = DOTween.Sequence(); // sequence.Append(transform.DOMoveX(40.0f, 3.0f).SetEase(Ease.InQuad)); // sequence.Join(transform.DOMoveY(40.0f, 3.0f)); //} void Update() { if (Input.GetKeyDown(KeyCode.A)) { Vector2 startPosition = Image.rectTransform.anchoredPosition; Vector2 targetPosition = startPosition; targetPosition.x = endX; StartCoroutine(KKUtilities.FloatLerp(3.0f, (t) => { Image.rectTransform.anchoredPosition = Vector2.LerpUnclamped(startPosition, targetPosition, Easing.GetEase(t, ease)); })); } }
IEnumerator DamageEffect() { profile.vignette.enabled = true; yield return(KKUtilities.FloatLerp(invincibleTime, (t) => { VignetteModel.Settings setting = profile.vignette.settings; setting.intensity = Mathf.Lerp(0.5f, 0.0f, t * t); profile.vignette.settings = setting; })); yield return(null); profile.vignette.enabled = false; }
public void CountUpText(int start, int end, float duration, bool vibrate = true) { if (vibrate) { StartCoroutine(VibrateCoroutine(duration * 0.8f)); } foreach (var c in coinNumTexts) { StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { c.Text = ((int)Mathf.Lerp(start, end, t)).ToString(); }, false)); } }
IEnumerator TitleLogoAnimation() { var wait = new WaitForSeconds(4.0f); while (true) { yield return(wait); yield return(KKUtilities.FloatLerp(3.0f, (t) => { titleLogoTransform.SetRotationZ(Mathf.LerpUnclamped(0.0f, 10.0f, rotationCurve.Evaluate(t))); })); } }
IEnumerator AlphaAnimation() { var wait = new WaitForSeconds(3.0f); while (true) { yield return(wait); yield return(KKUtilities.FloatLerp(2.0f, (t) => { message.Alpha = Mathf.Lerp(1.0f, 0.0f, Easing.Yoyo(Easing.InQuad(t))); })); } }
/// <summary> /// モード切替 /// </summary> public void PushUpBotton() { if (upMade == false) { upMade = true; canTapScaleButton = true; TapScaleImage(true); canTapRange.sizeDelta = new Vector2(canTapRange.sizeDelta.x, canTapRange.sizeDelta.y * TapRangeRatio); scaleButton.GetComponent <Image>().sprite = outButtonSprite[0]; SpriteState sprite; sprite.pressedSprite = outButtonSprite[1]; sprite.highlightedSprite = outButtonSprite[0]; sprite.disabledSprite = outButtonSprite[0]; scaleButton.spriteState = sprite; controlImage.gameObject.SetActive(true); StartCoroutine(KKUtilities.FloatLerp(0.3f, (t) => { contentGroup.alpha = Mathf.Lerp(1, 0, t); })); } else { TapScaleImage(false); canTapRange.sizeDelta = new Vector2(canTapRange.sizeDelta.x, canTapRange.sizeDelta.y / TapRangeRatio); scaleButton.GetComponent <Image>().sprite = upButtonSprite[0]; SpriteState sprite; sprite.pressedSprite = upButtonSprite[1]; sprite.highlightedSprite = upButtonSprite[0]; sprite.disabledSprite = upButtonSprite[0]; scaleButton.spriteState = sprite; controlImage.gameObject.SetActive(false); StartCoroutine(KKUtilities.FloatLerp(0.3f, (t) => { contentGroup.alpha = Mathf.Lerp(0, 1, t); })); upMade = false; } }
IEnumerator FadeCoroutine(Color startColor, Color endColor, float duration, Action action, float wait) { if (panel == null) { if (action != null) { action.Invoke(); } yield break; } panel.gameObject.SetActive(true); if (wait != 0.0f) { yield return(new WaitForSeconds(wait)); } //現在のパネルの色とフェードを開始する色に差異があったら0.5秒で調整する if (panel.color != startColor) { Color temp = panel.color; yield return (StartCoroutine(KKUtilities.FloatLerp(0.5f, (t) => { panel.color = Color.Lerp(temp, startColor, t); }))); } yield return (StartCoroutine(KKUtilities.FloatLerp(duration, (t) => { panel.color = Color.Lerp(startColor, endColor, t); }))); fadeCoroutine = null; panel.gameObject.SetActive(false); if (action != null) { action.Invoke(); } }
IEnumerator ChangePageAnimation(float targetRate, int pageIndex) { isAnimating = true; var start = currentRate; //t = s / d; var duration = Mathf.Abs(start - targetRate) / 1.0f; yield return(KKUtilities.FloatLerp(duration, (t) => { if (StorySimulator.Instance.PageEndAction != null) { return; } UpdateMovePage(Mathf.Lerp(start, targetRate, t)); })); currentPageIndex = pageIndex; UpdateTexture(currentPageIndex); UpdateMovePage(0.0f); isAnimating = false; }
//移動演出、 public void TapScaleImage(bool changeMode = false) { if (upMade == false) { return; } if (changeMode == false) { float tapJudgeTime = 0.4f; if (Time.time - downStartTime > tapJudgeTime) { return; } } float drawButtonPosition = 478; if (canTapScaleButton) { canTapScaleButton = false; StartCoroutine(KKUtilities.FloatLerp(0.3f, (t) => { scaleButton.GetComponent <RectTransform>().anchoredPosition = new Vector2(Mathf.Lerp(drawButtonPosition, drawButtonPosition + scaleButton.GetComponent <RectTransform>().sizeDelta.x, t), scaleButton.GetComponent <RectTransform>().anchoredPosition.y); })); } else { canTapScaleButton = true; StartCoroutine(KKUtilities.FloatLerp(0.3f, (t) => { scaleButton.GetComponent <RectTransform>().anchoredPosition = new Vector2(Mathf.Lerp(drawButtonPosition + scaleButton.GetComponent <RectTransform>().sizeDelta.x, drawButtonPosition, t), scaleButton.GetComponent <RectTransform>().anchoredPosition.y); })); } downStartTime = 0; }
IEnumerator EarnCoinAnimation(Vector3 origin, float popingDuration, float earnDuration) { var image = imagePool.GetInstance(); var rec = ((RectTransform)image.transform); rec.position = origin; float Radius = Random.Range(130.0f, 150.0f) * screenSizeRate; Vector3 midwayPos = rec.position + (-new Vector2(Random.Range(-1.0f, 1.0f), Random.value).normalized *Radius).ToXYVector3(); yield return(KKUtilities.FloatLerp(popingDuration, (t) => { rec.position = Vector3.Lerp(origin, midwayPos, Easing.OutQuad(t)); })); yield return(KKUtilities.FloatLerp(earnDuration, (t) => { rec.position = Vector3.Lerp(midwayPos, coinNumTextPos.position, Easing.OutCubic(t)); })); imagePool.ReturnInstance(image); }
IEnumerator EarnCoinShortAnimation(Vector3 origin, float popingDuration) { var image = imagePool.GetInstance(); origin = mainCamera.WorldToScreenPoint(origin); var rec = ((RectTransform)image.transform); rec.position = origin; float Radius = 150.0f * screenSizeRate; Vector3 midwayPos = rec.position + Vector3.up * Radius; yield return(KKUtilities.FloatLerp(popingDuration, (t) => { rec.position = Vector3.Lerp(origin, midwayPos, Easing.OutQuad(t)); })); yield return(KKUtilities.FloatLerp(0.3f, (t) => { image.transform.localScale = Vector3.one * Mathf.Lerp(1.0f, 0.0f, t); })); imagePool.ReturnInstance(image); }
public IEnumerator ShowAnimation() { var start = Vector2.zero; var end = Vector2.right * unmask.rect.width; var duration = 0.4f; if (MyGameManager.Instance.CurrentLevel < 5) { duration = 1.2f; } group.alpha = 1.0f; yield return(KKUtilities.FloatLerp(duration, (t) => { unmask.anchoredPosition = Vector2.Lerp(start, end, Easing.OutQuad(t)); })); foreach (var v in viewers) { v.PlayGaugeUpdateAnimation(); } }