/// <summary> /// Suspend (permanently stop) execution of current coroutine and start a new /// one, this is equivalent to exiting a state and entering another state. /// It also allow "EnterState" to trigger again its callback once it will be executed. /// This method also have callback /// </summary> /// <param name="nextState"> Next coroutine to be runned</param> /// <param name="onExitState"> Callback (Executed immediatly).</param> /// <returns> A Yieldable object (you can "yield return" it).</returns> public IYieldable Change( IEnumerator nextState, KoreCallback onExitState) { executed = false; onExitState(); change.NextState = nextState; return change; }
private IEnumerator RoundsCoroutine(KoreCallback gameEndedCallback) { int anturaGagRound = Random.Range(1, Configuration.NumberOfRounds); for (int round = 0; round < Configuration.NumberOfRounds; round++) { // Show antura only on the elected round. if (anturaGagRound == round) { yield return(Koroutine.Nested(AnturaGag())); } InitRound(); yield return(Koroutine.Nested(RoundBegin())); yield return(Koroutine.Nested(PlaceAnswers())); LogicInjector.EnableDragOnly(); if (round == 0) { executingRound0 = true; Koroutine.Run(DescriptionAudio()); } yield return(Koroutine.Nested(GamePlay())); executingRound0 = false; yield return(Koroutine.Nested(ClearRound())); } gameEndedCallback(); }
/// <summary> /// Prefer yielding this function instead of "null" to have a code that /// is more clear about its intent, also the callback will be executed /// only once when the state is entered /// </summary> /// <param name="onEnterState"> Callback (Executed immediatly).</param> /// <returns> A Yieldable object (you can "yield return" it).</returns> public IYieldable EnterState(KoreCallback onEnterState) { if (executed == false) { onEnterState(); executed = true; } return null; }
public void StartGameSession(KoreCallback gameEndedCallback) { Koroutine.Run(RoundsCoroutine(gameEndedCallback)); }
/// <summary> /// Suspend (permanently stop) execution of current coroutine and start a new /// one, this is equivalent to exiting a state and entering another state. /// </summary> /// <param name="state"> Next coroutine to be runned</param> /// <param name="callback"> Callback (Executed immediatly).</param> /// <returns> A Yieldable object (you can "yield return" it).</returns> public static IYieldable Change(IEnumerator state, KoreCallback callback) { callback(); State.StateChanger.NextState = state; return(State.StateChanger); }