/// <summary> /// This method requires some cleaning up. /// </summary> /// <returns></returns> public IEnumerator BowlingCycle() { //Bowling cycle while (true) { yield return(new WaitForSeconds(2)); //New Ball Event ball.Initialize(); EventManager.Instance.TriggerEvent(new NewBallEvent()); //Start new ball yield return(new WaitUntil(() => controller.IsReady())); state = States.Spinner; //Start spinner EventManager.Instance.TriggerEvent(new ToggleSpinnerEvent(true)); yield return(null); //Wait for player's input yield return(new WaitUntil(() => controller.IsReady())); state = States.Indicator; //Stop spinner, start indicator EventManager.Instance.TriggerEvent(new ToggleSpinnerEvent(false)); EventManager.Instance.TriggerEvent(new ToggleIndicatorEvent(true)); yield return(null); //Wait for player's input yield return(new WaitUntil(() => controller.IsReady())); state = States.Bouncer; //Stop indicator, start bounce selector EventManager.Instance.TriggerEvent(new ToggleIndicatorEvent(false)); EventManager.Instance.TriggerEvent(new ToggleBounceSelectorEvent(true)); yield return(null); //Wait for player's input yield return(new WaitUntil(() => controller.IsReady())); state = States.EndBall; //Stop bounce selector EventManager.Instance.TriggerEvent(new ToggleBounceSelectorEvent(false)); yield return(null); //Bowl ball.Bowl(); //Wait for player's input to start next bowling cycle yield return(new WaitUntil(() => state == States.NewBall)); } }