Exemplo n.º 1
0
        private IEnumerator MoveLeft(AnimatablePaper paper, int index)
        {
            paper.SetIsAnimating(true);

            LerpValue <Vector3> rotateToMiddle = paper.RotateToMiddle;

            while (rotateToMiddle.Continue())
            {
                paper.transform.localEulerAngles = Vector2.Lerp(rotateToMiddle.start, rotateToMiddle.end, rotateToMiddle.perc);
                yield return(null);
            }

            Audio.MusicPlayer.Instance.PlaySFXSound(Audio.SFXSound.TurningPage);
            paper.SetOrderInLayer(startSortingOrder + index);
            paper.SetIsOnBack(true);

            LerpValue <Vector3> rotateToOutside = paper.RotateToOutside;

            while (rotateToOutside.Continue())
            {
                paper.transform.localEulerAngles = Vector2.Lerp(rotateToOutside.start, rotateToOutside.end, rotateToOutside.perc);
                yield return(null);
            }

            paper.SetIsLeft(true);
            paper.SetIsAnimating(false);
        }
Exemplo n.º 2
0
        /// <summary>Returns an enumerator that notifies the player by showing a small screen on top of the screen and then hiding it after a delay</summary>
        private IEnumerator NotifyEnumerator(float stayTime)
        {
            isNotifying = true;

            float             offset       = notificationTransform.rect.height;
            LerpValue <float> movedownward = new LerpValue <float>(offset, -notificationTopSpacing, notifySpeed, LerpSettings.Cosine);

            while (movedownward.Continue())
            {
                Vector2 position = new Vector2(notificationTransform.anchoredPosition.x, Mathf.Lerp(movedownward.start, movedownward.end, movedownward.perc));
                notificationTransform.anchoredPosition = position;
                yield return(null);
            }

            yield return(new WaitForSeconds(stayTime + 4f));

            LerpValue <float> moveup = new LerpValue <float>(-notificationTopSpacing, offset, notifySpeed, LerpSettings.Cosine);

            while (moveup.Continue())
            {
                Vector2 position = new Vector2(notificationTransform.anchoredPosition.x, Mathf.Lerp(moveup.start, moveup.end, moveup.perc));
                notificationTransform.anchoredPosition = position;
                yield return(null);
            }

            if (notificationQueue.Count != 0)
            {
                StartNofication(notificationQueue.Dequeue());
            }
            else
            {
                isNotifying = false;
            }
        }
Exemplo n.º 3
0
    private void Update()
    {
        crosshair.gameObject.SetActive(!UIManager.instance.pause);

        cursorAlpha = crosshair.color;

        cursorAlpha.a   = LerpValue.SmoothRealtime(cursorAlpha.a, alphaTo, 12f);
        crosshair.color = cursorAlpha;

        if (target._run)
        {
            alphaTo = 0f;
            return;
        }
        else
        {
            alphaTo = 1f;
        }

        crosshair.transform.position     = Input.mousePosition;
        crosshair.transform.eulerAngles += Vector3.forward * 32f * Time.deltaTime;

        float inputFactor = (new Vector3(inputs.h, inputs.v, 0)).magnitude / 2;

        crosshair.transform.localScale = new Vector3(1 + inputFactor, 1 + inputFactor, 0);
    }
Exemplo n.º 4
0
    private void Start()
    {
        movement = GetComponent <Movement2D>();
        shape    = GetComponent <Shape>();

        mouthAngle = new LerpValue(ChangeMouthAnimationDirection, 40f);
    }
Exemplo n.º 5
0
 public SpinningWheel(IUIStyle style) : base(style)
 {
     fadeInAnim          = new SmoothValue(0, 1, FadeDuration, FadeDelay, AnimationLoop.NoLoop);
     rotationValue       = new LerpValue(0, MathHelper.Pi, 1, AnimationLoop.Loop);
     FadeIn              = true;
     Style.ValueChanged += OnStyleChanged;
 }
Exemplo n.º 6
0
 public ProgressBar(IUIStyle style) : base(style)
 {
     lerpValue = new LerpValue(0, 0, 0.5f, AnimationLoop.NoLoop);
     Min       = 0;
     Max       = 100;
     Value     = 0;
     Direction = ProgressBarDirection.LeftToRight;
 }
Exemplo n.º 7
0
            private void AddLerpValue(float distance, LerpValue lerpValue, ref float weight, ref float3 right, ref float3 up)
            {
                var other = GetTransform(distance + lerpValue.sampleDistance);

                right  += other.right * lerpValue.scale;
                up     += other.up * lerpValue.scale;
                weight += lerpValue.scale;
            }
Exemplo n.º 8
0
    private LerpValue sizeLerp; // Grows and Shrinks the value for the pellet size.

    private void Start()
    {
        sizeLerp = new LerpValue(ChangeSizeDirection, sizeRange.x, InterpolationMethod.Cosine)
        {
            Speed = animationSpeed
        };

        transform.localScale = Vector2.one * sizeLerp.Current;
    }
Exemplo n.º 9
0
        /// <summary>Returns an enumerator that linearly interpolates the alpha of the canvasgroup from 1 to 0</summary>
        public IEnumerator Intro()
        {
            LerpValue <float> alphaLerp = new LerpValue <float>(1, 0, transitionTime);

            while (alphaLerp.Continue())
            {
                group.alpha = Mathf.Lerp(alphaLerp.start, alphaLerp.end, alphaLerp.perc);
                yield return(null);
            }
        }
Exemplo n.º 10
0
        /// <summary>Returns an enumerator that changes the given source's volume of time towards targetVolume</summary>
        private IEnumerator ChangeSourceVolumeOverTime(AudioSource source, float targetVolume)
        {
            LerpValue <float> change = new LerpValue <float>(source.volume, targetVolume, themeTransitionFadeInTime);

            while (change.Continue())
            {
                source.volume = Mathf.Lerp(change.start, change.end, change.perc);
                yield return(null);
            }
        }
Exemplo n.º 11
0
        private IEnumerator MoveTowardsPlacementWithResult(PlacementResult result)
        {
            LerpValue<Vector3> move = new LerpValue<Vector3>(paperToPlace.transform.position, placement.transform.position, placeTime, LerpSettings.Cosine);
            LerpValue<Vector3> popdown = new LerpValue<Vector3>(paperToPlace.transform.localScale, Vector3.one, placeTime);
            while (move.Continue() && popdown.Continue())
            {
                paperToPlace.transform.position = Vector3.Lerp(move.start, move.end, move.perc);
                paperToPlace.transform.localScale = Vector3.Lerp(popdown.start, popdown.end, popdown.perc);
                yield return null;
            }

            OnPlacement(result);
        }
Exemplo n.º 12
0
        private IEnumerator PopupPaper(float time)
        {
            if (time == 0.0f)
            {
                yield break;
            }

            LerpValue<Vector3> popup = new LerpValue<Vector3>(Vector3.one, popupScale, time);
            while (popup.Continue())
            {
                paperToPlace.transform.localScale = Vector3.Lerp(popup.start, popup.end, popup.perc);
                yield return null;
            }
        }
Exemplo n.º 13
0
        private IEnumerator ConveyerBeltAnimation()
        {
            SetEnabledStateOfGroceries(false);

            LerpValue <Vector3> drag = new LerpValue <Vector3>(tfGroceries.position, tfAnimationEnd.position, animationTime);

            while (drag.Continue())
            {
                tfGroceries.position = Vector3.Lerp(drag.start, drag.end, drag.perc);
                yield return(null);
            }

            MusicPlayer.Instance.PlaySFXSound(SFXSound.PinTransactionStart);
            SetEnabledStateOfGroceries(true);
        }
Exemplo n.º 14
0
        /// <summary>Returns an enumerator that sets up by 2 characters by moving them towards the middle of the screen</summary>
        private IEnumerator SetupMonologue()
        {
            RectTransform rectTransform = (RectTransform)display.transform;

            float             x            = -rectTransform.sizeDelta.x;
            const int         HighResWidth = 1920;
            LerpValue <float> moveToMiddle = new LerpValue <float>(x, (x * 0.5f) + (HighResWidth * 0.5f), setupTime);

            while (moveToMiddle.Continue())
            {
                Vector3 towardsMiddle = new Vector3(Mathf.Lerp(moveToMiddle.start, moveToMiddle.end, moveToMiddle.perc), 0);
                rectTransform.anchoredPosition = towardsMiddle;
                yield return(null);
            }
        }
Exemplo n.º 15
0
        public Scrollbar(IUIStyle style) : base(style)
        {
            scrollbarPositionChangedSupport = new EventSupport <EventArgs>();
            scrollbarStyle = StyleSystem.StylesFor <ScrollbarStyleDefinition>();

            ScrollUnit = 50 / 120f;
            lerpOffset = new LerpValue(0, 0, 0.5f, AnimationLoop.NoLoop);

            MouseDragged += OnMouseDragged;
            MouseWheel   += OnMouseWheel;
            MouseUp      += OnMouseUp;
            MouseDown    += OnMouseDown;
            MouseClicked += OnMouseClick;

            Thumb = new ScrollbarThumb(UIStyle);
        }
Exemplo n.º 16
0
        /// <summary>Shifts this game object and its children towards given new shape over </summary>
        private IEnumerator ShiftShape(Shape newShape, float time)
        {
            shifting = true;

            LerpValue <Shape> shift  = new LerpValue <Shape>(currentShape, newShape, time);
            Shape             output = new Shape(currentShape);

            while (shift.Continue())
            {
                Shape.Shift(shift.start, shift.end, output, shift.perc).AssignValues(transform);
                yield return(null);
            }

            SetShape(newShape);
            shifting = false;
        }
    /// <summary>
    /// Returns an IEnumerator so that a MonoBehavior-derived class
    /// can run this function as a coroutine.  Animates the value
    /// between startValue and endValue using the lerpValue and applyValue
    /// delegates.
    /// </summary>
    /// <param name="startValue">
    /// The value to start at.
    /// </param>
    /// <param name="endValue">
    /// The value to end at.
    /// </param>
    /// <param name="lerpValue">
    /// A delegate that lerps the value.
    /// </param>
    /// <param name="applyValue">
    /// A delegate that does something with the value as it animates.
    /// </param>
    /// <returns>An IEnumerator for use in coroutines.</returns>
    public IEnumerator Animate(T startValue, T endValue,
                               LerpValue lerpValue, ApplyValue applyValue)
    {
        float progress = 0f;

        T value;

        while (progress < 1f)
        {
            value = lerpValue(startValue, endValue, progress);
            applyValue(value);
            progress += Time.deltaTime * _speed;
            yield return(null);
        }

        applyValue(endValue);
    }
Exemplo n.º 18
0
        /// <summary>Returns an enumerator that eases the slider towards given position</summary>
        private IEnumerator EaseTowardsPosition(Vector3 position)
        {
            isEasing = true;

            LerpValue <Vector3> ease = new LerpValue <Vector3>(rectTransform.anchoredPosition, position, easeTime);

            while (ease.Continue())
            {
                rectTransform.anchoredPosition = Vector3.Lerp(ease.start, ease.end, ease.perc);
                yield return(null);
            }

            //save x offset so the user can start sliding from this position
            offsetX = startX - rectTransform.position.x;

            isEasing = false;
        }
Exemplo n.º 19
0
        /// <summary>Returns an enumerator that toggles the size of the display</summary>
        private IEnumerator ToggleRoutine(int buttonCount)
        {
            isToggling  = true;
            targetWidth = defaultWidth + (EXPAND_PER_BUTTON * buttonCount);

            float             startWidth = hasFocus ? defaultWidth : targetWidth;
            float             endWidth   = hasFocus ? targetWidth : defaultWidth;
            LerpValue <float> changeSize = new LerpValue <float>(startWidth, endWidth, toggleTime);

            while (changeSize.Continue())
            {
                Vector2 sizeDelta = new Vector2(Mathf.Lerp(changeSize.start, changeSize.end, changeSize.perc), rectTransform.sizeDelta.y);
                rectTransform.sizeDelta = sizeDelta;
                yield return(null);
            }

            isToggling = false;
        }
Exemplo n.º 20
0
        private void Update()
        {
            bool duck  = Input.GetKeyDown(key);
            bool stand = Input.GetKeyUp(key);

            if (duck || stand)
            {
                //start new lerp movement when ducking is started on stopped
                duckOffsetStart = duckTransform.localPosition;
                move            = new LerpValue <Vector3>(duckOffsetStart, duck ? duckOffsetVector : startLocalPosition, duckTime, duckSetting);
                canDuck         = true;
            }

            if (!updateInFixedFrames)
            {
                Duck();
            }
        }
Exemplo n.º 21
0
        public override void Start()
        {
            randomSource = new Random();

            mushroomAnim        = new SmoothValue(1f, 0f, 0.3f);
            mushroomOpacityAnim = new SmoothValue(0f, 1f, 0.3f);
            logoAnim            = new LerpValue(0f, 1f, 0.3f, 0.3f);
            titleAnim           = new SmoothValue(0f, 10f, 3f, 0.1f);

            mushroomTex = Content.Load <Texture2D>("Sprites/Mushroom");
            titleTex    = Content.Load <Texture2D>("Sprites/NuclearWinterTitle");
            logoTex     = Content.Load <Texture2D>("Sprites/NuclearWinterLogo");

            sparklinLabsTex = Content.Load <Texture2D>("Sprites/SparklinLabs");

            switchTimer = new LerpValue(0f, 1f, 1f, 1.5f);

            base.Start();
        }
Exemplo n.º 22
0
        /// <summary>Returns a routine that translates the credit card in insertion position</summary>
        private IEnumerator MoveToPositionRoutine()
        {
            LerpValue <Vector3> move   = new LerpValue <Vector3>(debitCardTransform.anchoredPosition, insertStart, moveToPositionTime);
            LerpValue <Vector3> rotate = new LerpValue <Vector3>(Vector3.zero, new Vector3(0, 0, CARD_Z_ANGLE), moveToPositionTime);

            while (move.Continue() && rotate.Continue())
            {
                debitCardTransform.anchoredPosition = Vector3.Lerp(move.start, move.end, move.perc);
                debitCardTransform.eulerAngles      = Vector3.Lerp(rotate.start, rotate.end, rotate.perc);
                yield return(null);
            }

            SetMask(true);
            SetOutline(true);
            SetCardDraggability(true);
            SetInsertConstrained(true);

            isInserting = true;
        }
Exemplo n.º 23
0
        /// <summary>Returns an Enumerator that toggles the notification screen its state over time</summary>
        private IEnumerator NotificationScreenToggleEnumerator()
        {
            isToggling = true;

            float startScale = isScreenVisible ? 1.0f : 0.0f;
            float endScale   = isScreenVisible ? 0.0f : 1.0f;

            isScreenVisible = !isScreenVisible;

            LerpValue <Vector3> scale = new LerpValue <Vector3>(new Vector3(startScale, startScale), new Vector3(endScale, endScale), toggleTime);

            while (scale.Continue())
            {
                screenTransform.localScale = Vector3.Lerp(scale.start, scale.end, scale.perc);
                yield return(null);
            }

            isToggling = false;
        }
Exemplo n.º 24
0
        /// <summary>Returns an enumerator that sets up by 2 characters by moving them towards the middle of the screen</summary>
        private IEnumerator SetupDialogue()
        {
            RectTransform leftTransform  = (RectTransform)leftCharacterDisplay.transform;
            RectTransform rightTransform = (RectTransform)rightCharacterDisplay.transform;

            float leftX  = -leftTransform.sizeDelta.x;
            float rightX = rightTransform.sizeDelta.x;

            LerpValue <float> moveLeftDisplay  = new LerpValue <float>(leftX, 0, setupTime);
            LerpValue <float> moveRightDisplay = new LerpValue <float>(rightX, 0, setupTime);

            while (moveLeftDisplay.Continue() && moveRightDisplay.Continue())
            {
                Vector3 newLeft = new Vector3(Mathf.Lerp(moveLeftDisplay.start, moveLeftDisplay.end, moveLeftDisplay.perc), 0);
                leftTransform.anchoredPosition = newLeft;

                Vector3 newRight = new Vector3(Mathf.Lerp(moveRightDisplay.start, moveRightDisplay.end, moveRightDisplay.perc), 0);
                rightTransform.anchoredPosition = newRight;
                yield return(null);
            }
        }
Exemplo n.º 25
0
        private IEnumerator MagnifyEnumerator()
        {
            float offsetStretch;
            float offsetMoveUp;

            switch (Screen.height)
            {
            case 1440:
            {
                offsetStretch = Screen.height * 0.25f;
                offsetMoveUp  = Screen.height * 0.01f;
            }
            break;

            default:
            {
                offsetStretch = 450;
                offsetMoveUp  = 50;
            }
            break;
            }

            LerpValue <float> stretch = new LerpValue <float>(0, offsetStretch, 1.1f, LerpSettings.Cosine);
            LerpValue <float> moveup  = new LerpValue <float>(0, offsetMoveUp, 1.1f, LerpSettings.Cosine);

            while (stretch.Continue() && moveup.Continue())
            {
                Vector2 size = new Vector2(Mathf.Lerp(stretch.start, stretch.end, stretch.perc), Mathf.Lerp(stretch.start, stretch.end, stretch.perc));
                documentTransform.sizeDelta = size;


                Vector2 position = new Vector2(documentTransform.anchoredPosition.x, Mathf.Lerp(moveup.start, moveup.end, moveup.perc));
                documentTransform.anchoredPosition = position;

                yield return(null);
            }
        }
Exemplo n.º 26
0
        /// <summary>Returns an enumerator that either shows or hides the cellphone based on its current state</summary>
        private IEnumerator ToggleEnumerator()
        {
            isToggling = true;

            Vector3           position     = rectTransform.anchoredPosition;
            float             newYPosition = hasFocus ? -rectTransform.sizeDelta.y : 0;
            LerpValue <float> moveYAxis    = new LerpValue <float>(position.y, newYPosition, toggleTime);

            hasFocus = !hasFocus;

            if (!hasFocus)
            {
                ResetPinLoginPin();
            }

            while (moveYAxis.Continue())
            {
                Vector2 newPosition = new Vector2(position.x, Mathf.Lerp(moveYAxis.start, moveYAxis.end, moveYAxis.perc));
                rectTransform.anchoredPosition = newPosition;
                yield return(null);
            }

            isToggling = false;
        }
Exemplo n.º 27
0
 private float ChangeSizeDirection(LerpValue _lerpValue)
 {
     return((_lerpValue.Current == sizeRange.y) ? sizeRange.x : sizeRange.y);
 }
 protected GameStateFadeTransition(IBatchedDrawingService drawingService)
 {
     Transition     = new LerpValue(0, 1, TransitionDuration);
     DrawingService = drawingService ?? throw new ArgumentNullException(nameof(drawingService));
 }
Exemplo n.º 29
0
 private float ChangeMouthAnimationDirection(LerpValue _lerpValue)
 {
     return((Mathf.Approximately(_lerpValue.Current, maxMouthAngle)) ? MOUTH_CLOSED_ANGLE : maxMouthAngle);
 }
Exemplo n.º 30
0
 public Wind()
 {
     lerpSpeed  = new LerpValue(changeDuration, () => speed.RandomValue());
     lerpSwivel = new LerpValue(changeDuration, () => Random.Range(-swivel, swivel) * 180, true);
 }