public void ZoomOut() { if (!IsZoomed || !IsZoomInPlace) { return; } IsZoomed = false; IsZoomInPlace = false; GameController.Instance.Unpause(); foreach (GameObject cardGameObject in cardGameObjects) { LerpInformation <Vector3> positionLerpInformation = new LerpInformation <Vector3>( cardGameObject.transform.position, positionsBeforeZoom[cardGameObject], ZoomLerpDuration, Vector3.Lerp); zoomMovementLerpInformations[cardGameObject] = positionLerpInformation; LerpInformation <Quaternion> rotationLerpInformation = new LerpInformation <Quaternion>( cardGameObject.transform.rotation, rotationsBeforeZoom[cardGameObject], ZoomLerpDuration, Quaternion.Lerp); zoomRotationLerpInformations[cardGameObject] = rotationLerpInformation; } zoomScaleLperInformation = new LerpInformation <Vector3>(transform.localScale, new Vector3(0.5f, 0.5f, 1), ZoomLerpDuration, Vector3.Lerp); ZoomedOut?.Invoke(this, new CardStackEventArgs(this)); }
private void HandleVignetteFade() { if (vignetteFadeLerpInformation == null || vignetteFadeLerpInformation.TimeLeft <= 0) { vignetteFadeLerpInformation = null; return; } SetVignetteIntensity(vignetteFadeLerpInformation.Step(Time.deltaTime)); }
private static void HandleChipPullAwayLerp() { if (chipPullAwayLerpInformation == null || chipPullAwayLerpInformation.TimeLeft <= 0) { chipPullAwayLerpInformation = null; return; } ChipParent.position = chipPullAwayLerpInformation.Step(Time.deltaTime); }
private void HandleAlphaLerp() { if (alphaLerpInformation == null || alphaLerpInformation.TimeLeft <= 0) { alphaLerpInformation = null; return; } textComponent.color = new Color(1, 1, 1, alphaLerpInformation.Step(Time.deltaTime)); }
private void Move(Vector3 target) { movementLerpInformation = new LerpInformation <Vector3>(transform.position, target, MovementDuration, Vector3.Lerp); canMove = false; movementLerpInformation.Finished += (sender, args) => { movementLerpInformation = null; canMove = true; }; }
public void Zoom() { if (IsZoomed || cardMovementLerpInformations.Count > 0 || !IsZoomOutInPlace) { return; } IsZoomed = true; IsZoomOutInPlace = false; GameController.Instance.Pause(); zoomMovementLerpInformations.Clear(); zoomRotationLerpInformations.Clear(); positionsBeforeZoom.Clear(); rotationsBeforeZoom.Clear(); const float gapBetweenEachCard = 1.0f; float offset = (cardGameObjects.Count - 1) * gapBetweenEachCard / 2f; const float totalCardCurve = 50f; const float turnOffset = -1f * (totalCardCurve / 2f); float turnPerCard = totalCardCurve / cardGameObjects.Count; float rotationOffset = turnOffset + (cardGameObjects.Count - 1) * turnPerCard / 2f; float yOffsetScale = cardGameObjects.Count / 500f; for (int i = 0; i < cardGameObjects.Count; i++) { float zRotation = -(turnOffset + i * turnPerCard - rotationOffset); Quaternion destinationRotation = Quaternion.Euler(0, 0, zRotation); LerpInformation <Quaternion> rotationLerpInformation = new LerpInformation <Quaternion>(cardGameObjects[i].transform.rotation, destinationRotation, ZoomLerpDuration, Quaternion.Lerp); Vector3 destination = new Vector3(i * gapBetweenEachCard - offset, -(Mathf.Abs(zRotation) * yOffsetScale)); LerpInformation <Vector3> positionLerpInformation = new LerpInformation <Vector3>(cardGameObjects[i].transform.position, destination, ZoomLerpDuration, Vector3.Lerp); zoomMovementLerpInformations.Add(cardGameObjects[i], positionLerpInformation); zoomRotationLerpInformations.Add(cardGameObjects[i], rotationLerpInformation); positionsBeforeZoom.Add(cardGameObjects[i], cardGameObjects[i].transform.position); rotationsBeforeZoom.Add(cardGameObjects[i], cardGameObjects[i].transform.rotation); cardGameObjects[i].GetComponent <SpriteRenderer>().sortingLayerName = "Display Card"; } zoomScaleLperInformation = new LerpInformation <Vector3>(transform.localScale, Vector3.one, ZoomLerpDuration, Vector3.Lerp); ZoomedIn?.Invoke(this, new CardStackEventArgs(this)); }
private void Update() { HandleAlphaLerp(); if (zoomedOutCardStack == null || !zoomedOutCardStack.IsZoomOutInPlace) { return; } textComponent.enabled = true; textComponent.color = new Color(0, 0, 0, 0); zoomedOutCardStack = null; alphaLerpInformation = new LerpInformation <float>(0, 1, 0.1f, Mathf.Lerp); }
public void TurnOver() { if (!Card.IsFaceDown) { return; } Card.IsFaceDown = false; isTurnOverDone = false; Vector3 eulerAngles = transform.rotation.eulerAngles; eulerAngles.y = -90; cardTurnOverLerpInformation = new LerpInformation <Quaternion>(transform.rotation, Quaternion.Euler(eulerAngles), TurnOverDuration / 2f, Quaternion.Lerp); }
private void HandleZoom() { if (zoomScaleLperInformation == null || zoomScaleLperInformation.TimeLeft <= 0) { zoomScaleLperInformation = null; } else { transform.localScale = zoomScaleLperInformation.Step(Time.deltaTime); } foreach (GameObject cardGameObject in cardGameObjects) { if (!zoomMovementLerpInformations.ContainsKey(cardGameObject)) { continue; } if (zoomMovementLerpInformations[cardGameObject] == null || zoomMovementLerpInformations[cardGameObject].TimeLeft <= 0) { if (zoomMovementLerpInformations[cardGameObject]?.TimeLeft <= 0 && !IsZoomed) { cardGameObject.GetComponent <SpriteRenderer>().sortingLayerName = "Cards"; IsZoomOutInPlace = true; } else if (IsZoomed) { IsZoomInPlace = true; } zoomMovementLerpInformations[cardGameObject] = null; } else { cardGameObject.transform.position = zoomMovementLerpInformations[cardGameObject].Step(Time.deltaTime); } if (zoomRotationLerpInformations[cardGameObject] == null || zoomRotationLerpInformations[cardGameObject].TimeLeft <= 0) { zoomRotationLerpInformations[cardGameObject] = null; } else { cardGameObject.transform.rotation = zoomRotationLerpInformations[cardGameObject].Step(Time.deltaTime); } } }
private void Update() { if (cardTurnOverLerpInformation == null) { return; } if (!isTurnOverDone && cardTurnOverLerpInformation.TimeLeft <= 0) { SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.flipX = true; spriteRenderer.sprite = Card.FaceUpSprite; Vector3 eulerAngles = transform.rotation.eulerAngles; eulerAngles.y = -180; cardTurnOverLerpInformation = new LerpInformation <Quaternion>(transform.rotation, Quaternion.Euler(eulerAngles), TurnOverDuration / 2f, Quaternion.Lerp); isTurnOverDone = true; } transform.rotation = cardTurnOverLerpInformation.Step(Time.deltaTime); }
public void FadeVignette(float target, float duration) { vignetteFadeLerpInformation = new LerpInformation <float>(profile.vignette.settings.intensity, target, duration, Mathf.Lerp); }
public LerpInformationEventArgs(LerpInformation <T> lerpInformation) { LerpInformation = lerpInformation; }
public static void ReturnChips() { Vector3 destination = ChipParent.position + new Vector3(2f, -10, -ChipParent.position.z); chipPullAwayLerpInformation = new LerpInformation <Vector3>(ChipParent.position, destination, 0.4f, Vector3.Lerp); }