static IEnumerator <WaitCommand> InterleaveTest() { yield return(WaitCommand.Interleave( WaitSeconds("z", 5), InterleaveTest("a"), InterleaveTest("b"), InterleaveTest("c"))); }
static IEnumerator <WaitCommand> Subroutine(bool hasSubroutine, string prefix) { yield return(WaitCommand.Wait(5f.Seconds())); if (hasSubroutine) { yield return(WaitCommand.Interleave( Subroutine(false, prefix + prefix), Subroutine(false, prefix + prefix + "2"))); } yield return(WaitCommand.DontWait); Console.WriteLine(prefix + " subroutine"); }
private IEnumerator <WaitCommand> BeginChallenge(IChallenge challenge, FlightStatistics player) { if (_isChallengeStarting) { Debug.LogError("Challenge '" + challenge.Name + "' start is triggered while another challenge '" + _activeChallenge.Value.Name + "' is already starting"); yield break; } _isChallengeStarting = true; Debug.Log("Starting challenge: " + challenge.Name); yield return(WaitCommand.Interleave( challenge.Begin(player), _challengeAnnouncerUi.Introduce(challenge.ChallengeType.PrettyString(), Color.white, challenge.Name))); _isChallengeStarting = false; }
public IEnumerator <WaitCommand> Animate(Transform mount, Predicate isRunning) { var pathSelection = _cameraPaths.Paths; var selectedPath = pathSelection.RandomElement(); var isFirst = true; while (isRunning()) { selectedPath = pathSelection.GetNext(selectedPath); if (_gameSettingsProvider.IsVrActive) { selectedPath = new StaticCameraPath( Routines.LinearAnimation, selectedPath.Duration, selectedPath.To, to: selectedPath.To); } IEnumerator <WaitCommand> fadeIn; if (isFirst) { fadeIn = WaitCommand.DontWait.AsRoutine; isFirst = false; } else { fadeIn = _rig.ScreenFader.FadeIn(_clock, _faderSettings); } var fadeOut = WaitCommand.Wait(selectedPath.Duration - _faderSettings.FadeOutDuration) .AndThen(_rig.ScreenFader.FadeOut(_clock, _faderSettings)); var cameraAnimation = CameraAnimator.Animate(mount, selectedPath, _clock); yield return(WaitCommand .Interleave(fadeIn, cameraAnimation, fadeOut) .RunWhile(isRunning) .AsWaitCommand()); } _rig.ScreenFader.Opacity = 0f; }
static IEnumerator <WaitCommand> SimpleRoutine() { yield return(WaitCommand.WaitForNextFrame); Console.WriteLine("jaja"); yield return(WaitCommand.Wait(1f.Seconds())); Console.WriteLine("jaja2"); yield return(WaitCommand.Interleave( WaitCommand.Wait(20.Seconds()).AsRoutine, Subroutine(false, "aa"), Subroutine(true, "bb"), Subroutine(false, "cc"))); Console.WriteLine("first"); yield return(WaitCommand.Wait(1f.Seconds())); Console.WriteLine("second"); yield return(WaitCommand.Wait(1f.Seconds())); }