IEnumerator CoreLoop()
    {
        yield return(null);

        while (!Interrupt)
        {
            yield return(null);

            /*
             * Round starts, game chooses the next color to pick and than displays the
             * speech bubble and updates the flag and laterns.
             */
            IEnumerator start = StartCore();
            yield return(StartCoroutine(start));

            StopCoroutine(start);

            /*
             * Main Core beginning. Cannons beginning to shoot.
             */
            State = GameState.Gameplay;

            IEnumerator cannonFiring;

            if (PracticeFiring)
            {
                //Practice Firing is the first round and serves as the tutorial.
                cannonFiring   = CannonFireController.Instance.StartFiring();
                PracticeFiring = false;
            }
            else
            {
                //After the Practice Firing, game goes into the regular flow of the game.
                cannonFiring = CannonFireController.Instance.Firing();
            }

            yield return(StartCoroutine(cannonFiring));

            StopCoroutine(cannonFiring);

            IEnumerator waitForBags = PNHelper.CheckIfAllObjectsDisabled();
            yield return(StartCoroutine(waitForBags));

            StopCoroutine(waitForBags);

            CannonFireController.Instance.IncreaseDifficulty();
        }

        Interrupt = false;
    }
    IEnumerator Start()
    {
        //State - Start
        State = GameState.Start;

        UIManager.Instance.InitializeHighScore();

        //In-case there is a SplashScreen, let's wait in till it's over to begin the game.
        while (!SplashScreen.isFinished)
        {
            yield return(null);
        }

        //Display the intro text
        UIManager.Instance.CanvasMsgStart.SetActive(true);

        //Wait for the player to touch the screen
        yield return(StartCoroutine(PNHelper.WaitForClick()));

        //Remove the intro text
        UIManager.Instance.CanvasMsgStart.SetActive(false);

        if (PlayerPrefs.HasKey(TutorialKey) == false)
        {
            PlayerPrefs.SetInt(TutorialKey, 1);

            //Display the How To
            UIManager.Instance.CanvasMsgHowTo.SetActive(true);

            //Wait for the player to touch the screen
            yield return(StartCoroutine(PNHelper.WaitForClick()));

            //Remove the How to
            UIManager.Instance.CanvasMsgHowTo.SetActive(false);
        }

        while (true)
        {
            yield return(null);

            IEnumerator playSession = PlaySession();
            yield return(StartCoroutine(playSession));

            StopCoroutine(playSession);

            yield return(new WaitForSeconds(0.001f));
        }
    }
    IEnumerator End()
    {
        yield return(null);

        //Update Highscore
        UIManager.Instance.UpdateHighScore();

        //Update Score
        UIManager.Instance.UpdateScore();

        //UIManager should be toggling. OOP should be follow, able to reuse it
        //Display the End Message
        UIManager.Instance.CanvasMsgEnd.SetActive(true);

        yield return(StartCoroutine(PNHelper.WaitForClick()));

        //Remove the End Message
        UIManager.Instance.CanvasMsgEnd.SetActive(false);

        //Reset Everything
        Reset();
    }