private IEnumerator MoveOut() { _canvasGroup.interactable = false; var beg = ContainerToMove.anchoredPosition; var end = _origin + GetOffsetScreen(DirectionFrom); var routine = HelperTween.MoveRectTransformEnum( ContainerToMove, beg, end, Duration, Curve, true, () => { ContainerToMove.gameObject.SetActive(false); if (ActionOnFinish != null) { ActionOnFinish.Invoke(); } } ); return(routine); }
public IEnumerator AnimEndPanel(string newScoreTxt, string bestScoreTxt) { if (UIContainerGameplay != null) { UIContainerGameplay.GetComponent <CanvasGroup>().interactable = false; var routineMoveGameplayUI = HelperTween.MoveRectTransformEnum( UIContainerGameplay, UIContainerGameplay.anchoredPosition, UIContainerGameplay.anchoredPosition + Vector2.up * UIContainerGameplay.rect.height, 1f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true); yield return(StartCoroutine(routineMoveGameplayUI)); } UIContainerEndPanel.gameObject.SetActive(true); var routine = HelperTween.MoveRectTransformEnum( UIContainerEndPanel, UIContainerEndPanel.anchoredPosition, Vector2.zero, 1f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true); yield return(StartCoroutine(routine)); var str = newScoreTxt + "\n" + bestScoreTxt; var length = str.Length; for (float t = 0f, perc = 0f; perc < 1f; t += Time.unscaledDeltaTime) { perc = Mathf.Clamp01(t / DurationLetters); var nLetterToShow = (int)(length * perc); ScoreTxt.text = str.Substring(0, nLetterToShow); yield return(null); } routine = HelperTween.MoveRectTransformEnum( ButtonsEndPanel, ButtonsEndPanel.anchoredPosition, new Vector2(0f, 20f), 1f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true); yield return(StartCoroutine(routine)); ButtonsEndPanel.GetComponent <CanvasGroup>().interactable = true; }
public void SlowUp(Vector2 obj) { if (_routineSpeedup != null) { return; } if (_routineSlow != null) { _routineSlow = null; } _routineSpeedup = HelperTween.TimeScaleEnum(Time.timeScale, 1f, 0.15f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true); }
private IEnumerator MoveText(string msg) { TextRound.text = msg; ContainerText.gameObject.SetActive(true); var length = (ContainerText.root as RectTransform).rect.width; var beg = new Vector2(-length, 0f); yield return(HelperTween.MoveRectTransformEnum( ContainerText, beg, beg + new Vector2(length * 2f, 0f), DurationAnimText, CurveAnim, true)); ContainerText.gameObject.SetActive(false); }
public void Quit() { StartScreen.GetComponent <CanvasGroup>().interactable = false; Debug.Log(Vector2.down * StartScreen.rect.height); var routine = HelperTween.MoveRectTransformEnum( StartScreen, StartScreen.anchoredPosition, StartScreen.anchoredPosition + Vector2.down * StartScreen.rect.height, 1f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true, () => Application.Quit()); StartCoroutine(routine); }
private IEnumerator MoveIn() { ContainerToMove.gameObject.SetActive(true); var beg = ContainerToMove.anchoredPosition; var end = _origin; var routine = HelperTween.MoveRectTransformEnum( ContainerToMove, beg, end, Duration, Curve, true, () => _canvasGroup.interactable = true); return(routine); }
private IEnumerator FollowEnum() { var trans = transform; var origine = trans.position; var length = Points.Length; var onePathDuration = Duration / length; var lerpCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); int index = StartIndex % length; while (true) { var beg = Points[index] + origine; index = ++index % length; var end = Points[index] + origine; yield return(HelperTween.MoveTransformEnum(trans, beg, end, onePathDuration, lerpCurve, false)); } }
public void Play() { StartScreen.GetComponent <CanvasGroup>().interactable = false; Debug.Log( StartScreen.anchoredPosition); Debug.Log( StartScreen.anchoredPosition + Vector2.up * StartScreen.rect.height); var routine = HelperTween.MoveRectTransformEnum( StartScreen, StartScreen.anchoredPosition, StartScreen.anchoredPosition + Vector2.up * StartScreen.rect.height, 1f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f), true, () => SceneManager.LoadScene(1)); StartCoroutine(routine); }
private IEnumerator FireSlowMo() { Time.timeScale = 0f; //Move & scale StartCoroutine(HelperTween.MoveTransformEnum(TargetShoot.transform, TargetShoot.transform.position, _trans.position, 0.3f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f))); yield return(HelperTween.ScaleEnum(TargetShoot.transform, TargetShoot.transform.localScale, Vector3.zero, 0.3f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f))); TargetShoot.transform.position = _trans.position; TargetShoot.PawnRigid2D.velocity = Vector2.zero; if (OnShootPawn != null) { OnShootPawn(); } TargetShoot.PawnRigid2D.AddForce(_aimDir * ShootForce, ForceMode2D.Impulse); StartCoroutine(HelperTween.ScaleEnum(TargetShoot.transform, TargetShoot.transform.localScale, Vector3.one, 0.2f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f))); yield return(HelperTween.TimeScaleEnum(0f, 1f, 0.3f, AnimationCurve.EaseInOut(0f, 0f, 1f, 1f))); //Move & scale and timescale }