/// <summary> /// Offsets the camera by adjusting camera's lateral and vertical position, after everything else has been calculated. /// </summary> /// <returns></returns> public override Vector3 FinalPositionOffset() { Vector3 Offset = Vector3.zero; //Vertical Offsets float cameraHeightOffset = LerpUtility.Clerp(baseCameraHeight, baseCameraHeight + maxCameraHeight, HeightOffsetCurve, LastPlayerWallPercentage()); Offset = new Vector3(0f, cameraHeightOffset, 0f); // Lateral Offset if (CameraSway && GameController.instance.state == GameController.State.Round) { Vector3 lateralDeltaMove = transform.InverseTransformDirection(currentClosestRailNodeIndex.GetWorldPosition(GetCurrentLookOffsetT() + ExtraLookAhead) - currentClosestRailNodeIndex.GetWorldPosition(GetCurrentOffsetT() + ExtraLookAhead)); if (target != null) { lateralDeltaMove = transform.InverseTransformDirection(currentClosestRailNodeIndex.GetClosestPointOnRailSpline(target.transform.position) - currentClosestRailNodeIndex.GetWorldPosition(0f)); } if (Mathf.Abs(lateralDeltaMove.x) > 2f) { currentSway = LerpUtility.Clerp(currentSway, (lateralDeltaMove.x > 0 ? -MaxXSway : MaxXSway), FollowOffsetCurve, swaySensitivity * Time.deltaTime); currentSway = Mathf.Clamp(currentSway, -MaxXSway, MaxXSway); } else { currentSway = LerpUtility.Clerp(currentSway, 0f, FollowOffsetCurve, swaySensitivity * Time.deltaTime); } Offset += transform.right * currentSway; } return(Offset); }
public static IEnumerator Fade(this CanvasGroup group, float to, float duration) { if (!group.gameObject.activeInHierarchy) { yield break; } if (to == 0) { group.interactable = false; } if (group.alpha == to) { yield break; } yield return(LerpUtility.Lerp(group.alpha, to, duration, t => group.alpha = t, OnComplete)); void OnComplete() { if (to == 1) { group.interactable = true; } } }
/// <summary> /// where to look at in the world /// </summary> public override Vector3 WhereToLook() { Transform losingPlayer = GetLosingPlayer(); // CheckpointManager.instance.GetLosingPlayer(); Vector3? avPos = target != null ? target.position : GetAveragePlayerPosition(); float lookForwardT = GetCurrentLookOffsetT(); //LerpUtility.Clerp(lookForwardOffsetT, lookForwardOffsetT + addLookForwardOffT, LookAheadOffsetCurve, LastPlayerWallPercentage()); Vector3 lookAheadPos = currentClosestRailNodeIndex.GetClosestPointOnRailSpline(currentClosestRailNodeIndex.GetWorldPosition(lookForwardT)); if (avPos.HasValue) { if (losingPlayer != null) { Vector3 lastPlayerPos = losingPlayer.position; Vector3 baseLookPos = lookAheadPos; // (lookAheadPos + avPos.Value) * 0.5f; //Vector3 LookPos = LerpUtility.Clerp(lookAheadPos, (avPos.Value + lastPlayerPos) * 0.5f, HeightOffsetCurve, LastPlayerWallPercentage()); Vector3 LookPos = LerpUtility.Clerp(baseLookPos, (avPos.Value + lastPlayerPos) * 0.5f, HeightOffsetCurve, LastPlayerWallPercentage()); return(LookPos); } else { Debug.Log("No losing player!"); return(LerpUtility.Clerp(lookAheadPos, avPos.Value, FollowOffsetCurve, LastPlayerWallPercentage())); //avPos.Value; } } else { //Debug.Log("No average pos!"); return(currentClosestRailNodeIndex.GetWorldPosition(lookForwardOffsetT)); } }
IEnumerator Start() { Color startColor = ZenText.color; startColor.a = 0f; ZenText.color = startColor; TacleText.color = startColor; PlaybackUI.Instance.SetBackground(SceneUI.CurrentScene.BackgroundColor); SpiralManager.Instance.Camera.SetBackground(SceneUI.CurrentScene.BackgroundColor); if (SkipIntro) { OnCreate(); yield break; } yield return(new WaitForEndOfFrame()); PlaybackUI.Instance.StopAnimation(); Visuals.alpha = 1f; if (Application.platform == RuntimePlatform.WebGLPlayer) { yield return(new WaitForSeconds(1f)); } PlaybackUI.Instance.PlayAnimation(SceneUI.CurrentScene); yield return(new WaitForSeconds(1f)); Color endColor = startColor; endColor.a = 1f; Timer t = new Timer(2f); while (!t.IsFinished()) { yield return(0); ZenText.color = Color.Lerp(startColor, endColor, LerpUtility.Spherical(t.Percent())); TacleText.color = Color.Lerp(startColor, endColor, LerpUtility.Spherical(Mathf.Clamp01(t.Percent() * 1.4f - 0.4f))); } t.SetInterval(1f); t.Restart(); CreateButton.interactable = true; CreateButton.blocksRaycasts = true; while (!t.IsFinished()) { yield return(0); CreateButton.alpha = t.Percent(); } }
private void SetVolumeAll(List <AudioTrack.AudioPlayer> audioPlayers, float lerpRatio) { foreach (AudioTrack.AudioPlayer player in audioPlayers) { float max = player.Volume.Max; float min = player.Volume.Min; player.Audio.volume = Mathf.Clamp01(LerpUtility.Lerp(min, max, lerpRatio)); } }
IEnumerator scaleValue(Vector3 target) { Timer t = new Timer(0.25f); Vector3 start = Value.transform.parent.localScale; while (!t.IsFinished()) { yield return(0); Value.transform.parent.localScale = Vector3.Lerp(start, target, LerpUtility.HemiSpherical(t.Percent())); } }
void Update () { if (isRunning == false) { return; } currentTime += Time.deltaTime; var t = Mathf.Max (0f, currentTime); t = t / duration; t = LerpUtility.EaseValue (t, ease); t = Mathf.Min (1f, t); if (t > 0f) { Lerp (t); } if (t == 1f) { Destroy(this); } }
private void Awake() { Instance = this; }
IEnumerator goToHeight(float newHeight) { float startHeight = rect.sizeDelta.y; Timer t = new Timer(dropTime); while (!t.IsFinished()) { yield return(0); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.Lerp(startHeight, newHeight, LerpUtility.HemiSpherical(t.Percent()))); } }
public float GetCurrentLookOffsetT() { return(LerpUtility.Clerp(lookForwardOffsetT, lookForwardOffsetT + addLookForwardOffT, LookAheadOffsetCurve, LastPlayerWallPercentage())); }
public float GetCurrentOffsetT() { return(LerpUtility.Clerp(-followOffsetT, -followOffsetT + -addFollowOffsetT, FollowOffsetCurve, LastPlayerWallPercentage())); }
public void Execute(IWriteableWorld world) { world.Write(x => x.Fertility = LerpUtility.LerpFromLowToHigh(100000, world.Count <Person> (), 1f, 0.1f)); }