예제 #1
0
    private void MySceneLoaderChecker(Scene scene, LoadSceneMode mode)
    {
        if (scene.name.Equals(playScene))           // if we load the play scene
        {
            if (gameStartedFromMenu)
            {
                //setting data for the start of the game
                score = 0;
                lifes = 3;
                timer = 120f;

                if (AdManager.instance.areAllAdsLoaded())                   // continue ad logic only if all the ads are loaded
                {
                    GamePreferences.IncrementAdsCounter();                  // everytime we start a new game the ads counter it's incremented by one
                }
                //seding data to game controllers
                ScoreManager.instance.takeDataFromGameManager(score, lifes);
                CircleController.setTimer(timer);
            }
            else if (gameReplayed)
            {
                // making the view
                UIManager.instance.changeLifesUi(lifes);

                // sending data to game controllers
                CircleController.setTimer(timer);
                ScoreManager.instance.takeDataFromGameManager(score, lifes);
            }
            // we send all the data to other classes during the game so they will process the data and it will not be lost
        }
        else if (scene.name.Equals(menuScene))
        {
            if (GamePreferences.ShouldShowAd())            // it  verifies if we reached GamePreferences.ADD_NUMBER_SHOW to show ad
            {
                AdManager.instance.ShowUIAd();
            }
        }

        AdManager.instance.RequestAllAds();          // request ads everytime we load a new scene
    }