diff --git a/Assets/Scripts/Timer.cs b/Assets/Scripts/Timer.cs index e9e1e6c..7dbb9b4 100644 --- a/Assets/Scripts/Timer.cs +++ b/Assets/Scripts/Timer.cs @@ -17,29 +17,26 @@ void Start() { monoBehaviours = gameObject.GetComponents(); StartCoroutine(TimerCoroutine()); - } - - IEnumerator TimerCoroutine() - { - float elapsedTime = 0; - - while (elapsedTime <= waitTime) - { - elapsedTime += Time.deltaTime; - yield return null; + } + + IEnumerator TimerCoroutine() + { + float elapsedTime = 0; + + while (elapsedTime <= waitTime) + { + elapsedTime += Time.deltaTime; + yield return null; } - CheckExecutableActions(); + ExecuteActions(); } - private void CheckExecutableActions() - { - foreach (MonoBehaviour monoBehaviour in monoBehaviours) - { - if (monoBehaviour is IExecutableAction) - { - IExecutableAction actionableObject = (IExecutableAction)monoBehaviour; - actionableObject.ExecuteAction(); - } - } + private void ExecuteActions() + { + IExecutableAction[] actions = GetComponents(); + foreach(IExecutableAction action in actions) + { + action.ExecuteAction(); + } } }