private IEnumerator MoveInPlaceImpl(SecretaryAnimObject mechanicView, Auditor info) { yield return(new WaitForSeconds(.2f)); Vector3Animator scaleAnimator = mechanicView.gameObject.GetOrAdd <Vector3Animator>(); Vector2Animator positionAnimator = mechanicView.gameObject.GetOrAdd <Vector2Animator>(); FloatAnimator rotateAnimator = mechanicView.gameObject.GetOrAdd <FloatAnimator>(); RectTransform rectTransform = mechanicView.GetComponent <RectTransform>(); Vector2 startPosition = rectTransform.anchoredPosition; Vector2 endPosition = mechanicView.rightPosition; Vector2AnimationData positionData = new Vector2AnimationData { StartValue = startPosition, EndValue = endPosition, Duration = .3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdatePositionFunctor(), OnUpdate = rectTransform.UpdatePositionTimedFunctor(), OnEnd = rectTransform.UpdatePositionFunctor(() => { mechanicView.Setup(info); auditorViews.Add(mechanicView.Auditor.Id, mechanicView); animatedViews.Remove(mechanicView.Auditor.Id); }) }; Vector3AnimationData scaleData = new Vector3AnimationData { StartValue = 2f * Vector3.one, EndValue = Vector3.one, Duration = .3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdateScaleFunctor(), OnUpdate = rectTransform.UpdateScaleTimedFunctor(), OnEnd = rectTransform.UpdateScaleFunctor() }; FloatAnimationData rotateData = new FloatAnimationData { StartValue = rectTransform.localRotation.eulerAngles.z, EndValue = 0, Duration = .3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdateZRotation(), OnUpdate = rectTransform.UpdateZRotationTimed(), OnEnd = rectTransform.UpdateZRotation() }; positionAnimator.StartAnimation(positionData); scaleAnimator.StartAnimation(scaleData); rotateAnimator.StartAnimation(rotateData); }
private void AnimateAuditorObject(SecretaryAnimObject mechanicView, Auditor info) { Vector3Animator scaleAnimator = mechanicView.gameObject.GetOrAdd <Vector3Animator>(); Vector2Animator positionAnimator = mechanicView.gameObject.GetOrAdd <Vector2Animator>(); ColorAnimator colorAnimator = mechanicView.gameObject.GetOrAdd <ColorAnimator>(); FloatAnimator rotateAnimator = mechanicView.gameObject.GetOrAdd <FloatAnimator>(); RectTransform rectTransform = mechanicView.GetComponent <RectTransform>(); Image image = mechanicView.GetComponent <Image>(); Vector2 endOffset = Random.insideUnitCircle.normalized * 300; if (endOffset.y < 0) { endOffset.y = -endOffset.y; } Vector2 startPosition = buyButton.GetComponent <RectTransform>().anchoredPosition; Vector2 endPosition = startPosition + endOffset; Vector2AnimationData positionData = new Vector2AnimationData { StartValue = startPosition, EndValue = endPosition, Duration = 0.3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdatePositionFunctor(), OnUpdate = rectTransform.UpdatePositionTimedFunctor(), OnEnd = rectTransform.UpdatePositionFunctor(() => { StartCoroutine(MoveInPlaceImpl(mechanicView, info)); }) }; Vector3AnimationData scaleData = new Vector3AnimationData { StartValue = Vector3.one, EndValue = 2f * Vector3.one, Duration = .3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdateScaleFunctor(), OnUpdate = rectTransform.UpdateScaleTimedFunctor(), OnEnd = rectTransform.UpdateScaleFunctor() }; ColorAnimationData colorData = new ColorAnimationData { StartValue = new Color(1, 1, 1, 0), EndValue = new Color(1, 1, 1, 1), Duration = .1f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = image.UpdateColorFunctor(), OnUpdate = image.UpdateColorTimedFunctor(), OnEnd = image.UpdateColorFunctor() }; FloatAnimationData rotateData = new FloatAnimationData { StartValue = 0, EndValue = Random.Range(-40, 40), Duration = .3f, EaseType = EaseType.EaseInOutQuad, Target = mechanicView.gameObject, OnStart = rectTransform.UpdateZRotation(), OnUpdate = rectTransform.UpdateZRotationTimed(), OnEnd = rectTransform.UpdateZRotation() }; positionAnimator.StartAnimation(positionData); scaleAnimator.StartAnimation(scaleData); colorAnimator.StartAnimation(colorData); rotateAnimator.StartAnimation(rotateData); }