private IEnumerator StartNextPhaseAfterGivenDelay(NextPhase nextPhase, float delay) { // changing this to check if there is any skip used while wait for delay is happening... // so we comment the original code and wait for every second until the time asked in delay is complete or is been interuptted by user pressing buttons to interupt. // yield return new WaitForSeconds(delay); // nextPhase(); if (delay >= 1f) { var startTime = 0f; while (startTime < delay) { if (!stopthedelay) { yield return(new WaitForSeconds(1f)); startTime += 1.0f; } else { startTime = delay; } } stopthedelay = false; } else { yield return(new WaitForSeconds(delay)); } nextPhase(); yield return(null); }
private void Start() { nextPhase = GameObject.FindGameObjectWithTag("finish").GetComponent <NextPhase>(); }
private void PlayNextPhase(NextPhase nextPhase, float delay) { StartCoroutine(StartNextPhaseAfterGivenDelay(nextPhase, delay)); }
public static void UnsubscribeAllSubscriber() { if (NextPhase != null) { System.Delegate[] delegates = NextPhase.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { NextPhase -= delegates [i] as NextPhaseEvent; } } if (AllowCurrentPlayerToMove != null) { System.Delegate[] delegates = AllowCurrentPlayerToMove.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { AllowCurrentPlayerToMove -= delegates [i] as AllowCurrentPlayerToMoveEvent; } } if (DisallowCurrentPlayerToMove != null) { System.Delegate[] delegates = DisallowCurrentPlayerToMove.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { DisallowCurrentPlayerToMove -= delegates [i] as DisallowCurrentPlayerToMoveEvent; } } if (AllowCurrentPlayerToFire != null) { System.Delegate[] delegates = AllowCurrentPlayerToFire.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { AllowCurrentPlayerToFire -= delegates [i] as AllowCurrentPlayerToFireEvent; } } if (DisallowCurrentPlayerToFire != null) { System.Delegate[] delegates = DisallowCurrentPlayerToFire.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { DisallowCurrentPlayerToFire -= delegates [i] as DisallowCurrentPlayerToFireEvent; } } if (NextPlayer != null) { System.Delegate[] delegates = NextPlayer.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { NextPlayer -= delegates [i] as NextPlayerEvent; } } if (PlayerDead != null) { System.Delegate[] delegates = PlayerDead.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { PlayerDead -= delegates [i] as PlayerDeadEvent; } } if (PlayerWon != null) { System.Delegate[] delegates = PlayerWon.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { PlayerWon -= delegates [i] as PlayerWonEvent; } } if (TimerEnd != null) { System.Delegate[] delegates = TimerEnd.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { TimerEnd -= delegates [i] as TimerEndEvent; } } if (PlayerCast != null) { System.Delegate[] delegates = PlayerCast.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { PlayerCast -= delegates [i] as PlayerCastEvent; } } if (SpellEnd != null) { System.Delegate[] delegates = SpellEnd.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { SpellEnd -= delegates [i] as SpellEndEvent; } } if (NextPlayerButtonClick != null) { System.Delegate[] delegates = NextPlayerButtonClick.GetInvocationList(); for (int i = 0; i < delegates.Length; i++) { NextPlayerButtonClick -= delegates [i] as NextPlayerButtonClickEvent; } } }