public void update()
        {
            Vector2 cameraPos         = transform.position;
            Vector2 objectToFollowPos = ObjectToFollow.position;

            float halfWidth  = _camera.bounds.width / 2.0f;
            float halfHeight = _camera.bounds.height / 2.0f;

            if (!Deadzone.Contains(objectToFollowPos))
            {
                cameraPos = Lerps.ease(EaseType.QuadInOut, cameraPos, objectToFollowPos, SmoothTime, 1.0f);
                // cameraPos = Lerps.lerpDamp(cameraPos, objectToFollowPos, SmoothSpeed);
            }
            if (cameraPos.X - halfWidth < MapEdge.Min.X)
            {
                cameraPos.X = MapEdge.Min.X + halfWidth;
            }
            if (cameraPos.Y - halfHeight < MapEdge.Min.Y)
            {
                cameraPos.Y = MapEdge.Min.Y + halfHeight;
            }
            if (cameraPos.X + halfWidth > MapEdge.Max.X)
            {
                cameraPos.X = MapEdge.Max.X - halfWidth;
            }
            if (cameraPos.Y + halfHeight > MapEdge.Max.Y)
            {
                cameraPos.Y = MapEdge.Max.Y - halfHeight;
            }



            transform.position = cameraPos;
        }
Пример #2
0
        /// <summary>
        /// the most common type of transition seems to be one that ticks progress from 0 - 1. This method takes care of that for you
        /// if your transition needs to have a _progress property ticked after the scene loads.
        /// </summary>
        /// <param name="duration">duration</param>
        /// <param name="reverseDirection">if true, _progress will go from 1 to 0. If false, it goes form 0 to 1</param>
        public IEnumerator tickEffectProgressProperty(Effect effect, float duration, EaseType easeType = EaseType.ExpoOut, bool reverseDirection = false)
        {
            var start         = reverseDirection ? 1f : 0f;
            var end           = reverseDirection ? 0f : 1f;
            var progressParam = effect.Parameters["_progress"];

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed += Time.deltaTime;
                var step = Lerps.ease(easeType, start, end, elapsed, duration);
                progressParam.SetValue(step);

                yield return(null);
            }
        }
Пример #3
0
        public override IEnumerator onBeginTransition()
        {
            yield return(null);

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed        += Time.deltaTime;
                _renderScale    = Lerps.ease(scaleEaseType, maxScale, minScale, elapsed, duration);
                _renderRotation = Lerps.ease(rotationEaseType, minRotation, maxRotation, elapsed, duration);

                yield return(null);
            }

            // load up the new Scene
            yield return(Core.startCoroutine(loadNextScene()));

            // dispose of our previousSceneRender. We dont need it anymore.
            previousSceneRender.Dispose();
            previousSceneRender = null;

            yield return(Coroutine.waitForSeconds(delayBeforeMaskOut));

            elapsed = 0f;
            while (elapsed < duration)
            {
                elapsed     += Time.deltaTime;
                _renderScale = Lerps.ease(
                    EaseHelper.oppositeEaseType(scaleEaseType),
                    minScale,
                    maxScale,
                    elapsed,
                    duration);
                _renderRotation = Lerps.ease(
                    EaseHelper.oppositeEaseType(rotationEaseType),
                    maxRotation,
                    minRotation,
                    elapsed,
                    duration);

                yield return(null);
            }

            transitionComplete();
        }
Пример #4
0
        /// <summary>
        /// animates the letterbox in
        /// </summary>
        /// <returns>The in.</returns>
        /// <param name="letterboxSize">Letterbox size.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easeType">Ease type.</param>
        public IEnumerator animateIn(float letterboxSize, float duration = 2, EaseType easeType = EaseType.ExpoOut)
        {
            // wait for any current animations to complete
            while (_isAnimating)
            {
                yield return(null);
            }

            _isAnimating = true;
            var elapsedTime = 0f;

            while (elapsedTime < duration)
            {
                elapsedTime       += Time.deltaTime;
                this.letterboxSize = Lerps.ease(easeType, 0, letterboxSize, elapsedTime, duration);
                yield return(null);
            }
            _isAnimating = false;
        }
        public override IEnumerator onBeginTransition()
        {
            yield return(null);

            // load up the new Scene
            yield return(Core.startCoroutine(loadNextScene()));

            var elapsed = 0f;

            while (elapsed < fadeDuration)
            {
                elapsed += Time.deltaTime;
                _color   = Lerps.ease(fadeEaseType, ref _fromColor, ref _toColor, elapsed, fadeDuration);

                yield return(null);
            }

            transitionComplete();
        }
Пример #6
0
        public override IEnumerator onBeginTransition()
        {
            yield return(null);

            // load up the new Scene
            yield return(Core.startCoroutine(loadNextScene()));

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed         += Time.deltaTime;
                _destinationRect = Lerps.ease(transitionEaseType, ref _textureBounds, ref _finalRenderRect, elapsed, duration);

                yield return(null);
            }

            transitionComplete();
        }
Пример #7
0
        public override IEnumerator onBeginTransition()
        {
            // create a single pixel texture of our fadeToColor
            _overlayTexture = Graphics.createSingleColorTexture(1, 1, fadeToColor);

            var elapsed = 0f;

            while (elapsed < fadeOutDuration)
            {
                elapsed += Time.deltaTime;
                _color   = Lerps.ease(fadeEaseType, ref _toColor, ref _fromColor, elapsed, fadeOutDuration);

                yield return(null);
            }

            // load up the new Scene
            yield return(Core.startCoroutine(loadNextScene()));

            // dispose of our previousSceneRender. We dont need it anymore.
            previousSceneRender.Dispose();
            previousSceneRender = null;

            yield return(Coroutine.waitForSeconds(delayBeforeFadeInDuration));

            elapsed = 0f;
            while (elapsed < fadeInDuration)
            {
                elapsed += Time.deltaTime;
                _color   = Lerps.ease(
                    EaseHelper.oppositeEaseType(fadeEaseType),
                    ref _fromColor,
                    ref _toColor,
                    elapsed,
                    fadeInDuration);

                yield return(null);
            }

            transitionComplete();
            _overlayTexture.Dispose();
        }
Пример #8
0
        /// <summary>
        /// animates the flash
        /// </summary>
        /// <returns>The in.</returns>
        /// <param name="letterboxSize">Letterbox size.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="easeType">Ease type.</param>
        public IEnumerator animate(float fadeDuration, EaseType easeType = EaseType.SineOut)
        {
            // wait for any current animations to complete
            while (_isAnimating)
            {
                yield return(null);
            }

            flashIntensity = 1.0f;

            _isAnimating = true;
            var elapsedTime = 0f;

            while (elapsedTime < fadeDuration)
            {
                elapsedTime   += Time.deltaTime;
                flashIntensity = Lerps.ease(easeType, 1, 0, elapsedTime, fadeDuration);
                yield return(null);
            }
            _isAnimating = false;
        }