private void ClipReload() { string clipName = currentClipName; atLeastOneLoop = true; this.TimeDelayCall(() => { if (currentClipName == clipName) { UnloadCurrentClip(); this.RealtimeDelayCall(() => { if (currentClipName == clipName) { LoadLiveClip(clipName); SetReadyText(); } }, 0.1f); } }, Mathf.Max(currentClip.postDelay, 0.1f)); // reason for this value: 0.07f is slightly longer than the 0.05f delay // from a few lines up float epsilon = 0.07f; float delayBeforeFade = currentClip.postDelay / 4; float totalTransitionDuration = Mathf.Max(delayBeforeFade + epsilon, 0.1f); this.TimeDelayCall( () => TransitionUtility.OneShotFadeTransition(totalTransitionDuration * 2, totalTransitionDuration * 3), delayBeforeFade * .3f); }
private void LerpFontSize() { StartCoroutine( TransitionUtility.PingPongFloat( (newScale) => rect.localScale = new Vector3(newScale, newScale, 1.0f), minRectScale, maxRectScale, period, useGameTime: false, animationCurve: fontSizeCurve)); }
private void FlashNullZone() { AudioManager.instance.PassToNullZone.Play(.1f); StartCoroutine(TransitionUtility.LerpColor(color => renderer.color = color, renderer.color, flashColor, flashTransitionDuration)); this.RealtimeDelayCall(() => FlashBackToNormal(), stayedFlashDuration + flashTransitionDuration); }
private void FlashBackToNormal(Color startingColor) { SpriteRenderer renderer = GetComponent <SpriteRenderer>(); if (renderer == null) { return; } StartCoroutine(TransitionUtility.LerpColor(color => renderer.color = color, renderer.color, startingColor, flashTransitionDuration)); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
private void StartChargeShot() { shotChargeIndicator.Show(); chargeShotCoroutine = StartCoroutine(TransitionUtility.LerpFloat((value) => { this.shotSpeed = value; shotChargeIndicator.FillAmount = value; }, startValue: baseShotSpeed, endValue: maxShotSpeed, duration: maxChargeShotTime, useGameTime: true, animationCurve: chargeShotCurve) ); }
private void FlashNullZone() { if (this == null) { return; } SpriteRenderer renderer = this.EnsureComponent <SpriteRenderer>(); Color startingColor = renderer.color; StartCoroutine(TransitionUtility.LerpColor(color => renderer.color = color, renderer.color, flashColor, flashTransitionDuration)); this.RealtimeDelayCall(() => FlashBackToNormal(startingColor), stayedFlashDuration + flashTransitionDuration); }
public void DisplayNextPoint() { // Scores are 1-indexed, pointIndicators are 0-indexed // ASSUMPTION: this function is invoked *after* team.score has been updated int nextPoint = team.Score - 1; GameObject pointIndicator = pointIndicators[nextPoint]; SpriteRenderer renderer = pointIndicator.GetComponent <SpriteRenderer>(); renderer.sprite = team.resources.scoreIndicatorFullSprite; StartCoroutine(TransitionUtility.LerpColorSequence( (Color color) => renderer.color = color, stops, durations)); StartParticleEffect(pointIndicator); }
public void GameOverFunction() { endText.color = GameManager.instance.winner.teamColor.color; endText.text = endTextContent; // Start "Game!" text lerp StartCoroutine( TransitionUtility.LerpFloat( (float value) => { float scaledProgress = textSize.Evaluate(value); endText.fontSize = (int)Mathf.Lerp( minTextSize, maxTextSize, scaledProgress); }, 0.0f, 1.0f, textLerpDuration)); }
private void LerpColor() { StartCoroutine( TransitionUtility.PingPongColor( (value) => { if (text != null) { text.color = value; } else if (richText != null) { richText.color = value; } }, startColor, endColor, period, useGameTime: false, animationCurve: colorCurve)); }
// Warning: this function may be called any time the player presses the A // button (or whatever xbox controller button is bound to shoot). This // includes dash private void OnShootPressed() { bool shootTimerRunning = shootTimer != null; bool alreadyChargingShot = chargeShot != null; if (stateManager.IsInState(State.Posession) && shootTimerRunning && !alreadyChargingShot) { shotChargeIndicator.Show(); chargeShot = StartCoroutine(TransitionUtility.LerpFloat((value) => { this.shotSpeed = value; shotChargeIndicator.FillAmount = value; }, startValue: baseShotSpeed, endValue: maxShotSpeed, duration: maxChargeShotTime, useGameTime: true, animationCurve: chargeShotCurve)); } }
private IEnumerator ResetCountdown() { restartText.text = "Resetting in: "; for (int i = SecondsBeforeReset; i > 0; --i) { restartCount.text = i.ToString(); StartCoroutine( TransitionUtility.LerpFloat( (float value) => { float scaledProgress = restartCountSize.Evaluate(value); restartCount.fontSize = (int)Mathf.Lerp( minRestartCountSize, maxRestartCountSize, scaledProgress); }, 0.0f, 1.0f, restartCountDuration)); yield return(new WaitForSecondsRealtime(restartCountDuration + epsilon)); } SceneStateManager.instance.Load(Scene.Court); }
private void FlashBackToNormal() { StartCoroutine(TransitionUtility.LerpColor(color => renderer.color = color, renderer.color, startingColor, flashTransitionDuration)); }
private IEnumerator Clips() { runningLiveClips = true; StartListeningForPlayers(); GameManager.NotificationManager.CallOnMessage(Message.RecordingFinished, () => { if (!clipReloadThisFrame) { ClipReload(); clipReloadThisFrame = true; this.FrameDelayCall(() => clipReloadThisFrame = false, 3); } }); GameManager.NotificationManager.CallOnMessage(Message.RecordingInterrupt, SubclipInterrupt); yield return(null); ySkip.StartListening(); foreach (LiveClipInfo liveClip in liveClips) { clipReloadThisFrame = false; currentClip = liveClip; ResetCheckin(); currentClipName = liveClip.clipName; currentSubclips = liveClip.subclipInfo; yield return(new WaitForSecondsRealtime(liveClip.preDelay)); LoadLiveClip(currentClipName); yield return(null); while (!AllCheckedIn() && !ySkip.AllCheckedIn()) { yield return(null); } yield return(null); TransitionUtility.OneShotFadeTransition(0.3f, 0.2f); yield return(new WaitForSecondsRealtime(0.15f)); UnloadCurrentClip(); yield return(null); if (ySkip.AllCheckedIn()) { break; } } TransitionUtility.OneShotFadeTransition(0.1f, 0.4f); yield return(new WaitForSeconds(0.05f)); runningLiveClips = false; if (ySkip.AllCheckedIn()) { PlayerTutorial.SkipTutorial(); } else { SceneStateManager.instance.Load(Scene.Sandbox); } }
public static Coroutine ResetScene(string sceneName, float duration) { return(TransitionUtility.Transition(duration, ResetSceneEffect(sceneName))); }
/// <summary> /// Starts a scene transition and runs an action between fades. /// Requires Package scene or a derived scene to work. /// </summary> /// <param name="curScene">Scene to be unloaded</param> /// <param name="nextScene">Scene to be loaded</param> /// <param name="duration">Duration of the transition</param> /// <param name="action">Action to be executed</param> public static Coroutine SceneTransition(string curScene, string nextScene, float duration, UnityAction action) { //return filter.StartCoroutine(SceneTransitionEffect(curScene, nextScene, filter, duration)); return(TransitionUtility.Transition(duration, SceneTransitionEffect(curScene, nextScene, action))); }
/// <summary> /// Starts a scene transition and runs an action between fades. /// Requires Package scene or a derived scene to work. /// </summary> /// <param name="curScene">Scene to be unloaded</param> /// <param name="nextScene">Scene to be loaded</param> /// <param name="duration">Duration of the transition</param> /// <param name="routine">Action to be executed</param> public static Coroutine SceneTransition(string curScene, string nextScene, float duration, IEnumerator routine) { //return filter.StartCoroutine(SceneTransitionEffect(curScene, nextScene, filter, duration)); return(TransitionUtility.Transition(duration, SceneTransitionEffect(TransitionUtility.TransitionImage, curScene, nextScene, routine))); }