/// <summary> /// <para>If currentLevelDuration surpass the levelDuration then the transition will start and it will invoke the /// LevelTransition event</para> /// <para>If transitioning is true and the currentLevelDuration is higher than the levelTransitionTime then the /// NextLevel event is Invoke and the currentLevel is increase.</para> /// </summary> private void Update() { if (transitioning && currentLevelDuration >= levelTransitionTime) { currentLevel++; levelUI.UpdateValue(currentLevel); NextLevel?.Invoke(currentLevel); currentLevelDuration = 0; transitioning = false; return; } if (currentLevelDuration >= levelDuration) { transitioning = true; LevelTransition?.Invoke(); currentLevelDuration = 0; return; } currentLevelDuration += Time.deltaTime; }