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); }
/// <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; } }
/// <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); } }
/// <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); } }
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); }
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; } }
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); }
/// <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); } }
/// <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 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; }
private void Duck() { if (canDuck) { //if we can duck, linearly interpolate towards end position if (move.Continue()) { duckTransform.localPosition = Vector3.Lerp(move.start, move.end, move.perc); } if (duckTransform.localPosition == startLocalPosition) { //if the localposition of the object is back to start, stop ducking canDuck = false; } } }
/// <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; }
/// <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; }
/// <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; }
/// <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); } }
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); } }
/// <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; }