Esempio n. 1
0
 public static void Trigger(float duration, Tweens.TweenCurve tween = Tweens.TweenCurve.LinearTween, int id = 0)
 {
     e._id       = id;
     e._duration = duration;
     e._curve    = tween;
     EventManager.TriggerEvent(e);
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MoreMountains.MMInterface.MMFadeEvent"/> struct.
 /// </summary>
 /// <param name="duration">Duration, in seconds.</param>
 /// <param name="targetAlpha">Target alpha, from 0 to 1.</param>
 public FadeEvent(float duration, float targetAlpha, Tweens.TweenCurve tween = Tweens.TweenCurve.LinearTween, int id = 0)
 {
     _id          = id;
     _duration    = duration;
     _targetAlpha = targetAlpha;
     _curve       = tween;
 }
Esempio n. 3
0
 protected virtual void StartFading(float initialAlpha, float endAlpha, float duration, Tweens.TweenCurve curve, int id)
 {
     if (id != _id)
     {
         return;
     }
     EnableFader();
     _fading             = true;
     _initialAlpha       = initialAlpha;
     _currentTargetAlpha = endAlpha;
     _fadeStartedAt      = _ignoreTimescale ? Time.unscaledTime : Time.time;
     _currentCurve       = curve;
     _currentDuration    = duration;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MoreMountains.MMInterface.MMFadeOutEvent"/> struct.
 /// </summary>
 /// <param name="duration">Duration.</param>
 public FadeOutEvent(float duration, Tweens.TweenCurve tween = Tweens.TweenCurve.LinearTween, int id = 0)
 {
     _id       = id;
     _duration = duration;
     _curve    = tween;
 }
Esempio n. 5
0
        protected static IEnumerator RotateTransformAroundCo(Transform targetTransform, Transform center, Transform destination, float angle, WaitForSeconds delay, float delayDuration, float duration, Tweens.TweenCurve curve)
        {
            if (delayDuration > 0f)
            {
                yield return(delay);
            }

            Vector3    initialRotationPosition = targetTransform.transform.position;
            Quaternion initialRotationRotation = targetTransform.transform.rotation;

            float rate = 1f / duration;

            float timeSpent = 0f;

            while (timeSpent < duration)
            {
                float newAngle = Tools.Tweens.Tween(timeSpent, 0f, duration, 0f, angle, curve);

                targetTransform.transform.position = initialRotationPosition;
                initialRotationRotation            = targetTransform.transform.rotation;
                targetTransform.RotateAround(center.transform.position, center.transform.up, newAngle);
                targetTransform.transform.rotation = initialRotationRotation;

                timeSpent += Time.deltaTime;
                yield return(null);
            }
            targetTransform.transform.position = destination.position;
        }
Esempio n. 6
0
 public static Coroutine RotateTransformAround(MonoBehaviour mono, Transform targetTransform, Transform center, Transform destination, float angle, WaitForSeconds delay, float delayDuration, float duration, Tweens.TweenCurve curve)
 {
     return(mono.StartCoroutine(RotateTransformAroundCo(targetTransform, center, destination, angle, delay, delayDuration, duration, curve)));
 }
Esempio n. 7
0
        protected static IEnumerator MoveTransformCo(Transform targetTransform, Transform origin, Transform destination, WaitForSeconds delay, float delayDuration, float duration, Tweens.TweenCurve curve, bool updatePosition = true, bool updateRotation = true)
        {
            if (delayDuration > 0f)
            {
                yield return(delay);
            }
            float timeLeft = duration;

            while (timeLeft > 0f)
            {
                if (updatePosition)
                {
                    targetTransform.transform.position = Tools.Tweens.Tween(duration - timeLeft, 0f, duration, origin.position, destination.position, curve);
                }
                if (updateRotation)
                {
                    targetTransform.transform.rotation = Tools.Tweens.Tween(duration - timeLeft, 0f, duration, origin.rotation, destination.rotation, curve);
                }
                timeLeft -= Time.deltaTime;
                yield return(null);
            }
            if (updatePosition)
            {
                targetTransform.transform.position = destination.position;
            }
            if (updateRotation)
            {
                targetTransform.transform.localEulerAngles = destination.localEulerAngles;
            }
        }
Esempio n. 8
0
 public static Coroutine MoveTransform(MonoBehaviour mono, Transform targetTransform, Transform origin, Transform destination, WaitForSeconds delay, float delayDuration, float duration, Tweens.TweenCurve curve, bool updatePosition = true, bool updateRotation = true)
 {
     return(mono.StartCoroutine(MoveTransformCo(targetTransform, origin, destination, delay, delayDuration, duration, curve, updatePosition, updateRotation)));
 }