Esempio n. 1
0
    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
        playingSceneCanves  = FindObjectOfType <PlayingSceneCanves>();
        playingSceneManager = FindObjectOfType <PlayingSceneManager>();
        playerBall          = FindObjectOfType <PlayerBall>();
        startSceneCanves    = FindObjectOfType <StartSceneCanves>();
        openBallsManager    = FindObjectOfType <OpenBallsManager>();

        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished)
        {
            // Reward the user for watching the ad to completion.
            if (!isBallAd)
            {
                print("Player Finished the ad");
                playerBall.RevivePlayer();
                playingSceneCanves.HideAdMenu();
            }
            else
            {
                startSceneCanves.ChoosedBall.IsAdNeeded = false;
                startSceneCanves.SetBallSprite(startSceneCanves.ChoosedBall);//open the choosed ball if he watced the ad succesfuly
                startSceneCanves.HideLockedPanel();
            }
        }
        else if (showResult == ShowResult.Skipped)
        {
            // Do not reward the user for skipping the ad.
            if (!isBallAd)
            {
                print("Player Skipped the ad");
                playingSceneManager.LoseTheGame();
                playingSceneCanves.HideAdMenu();
            }
            else
            {
                startSceneCanves.HideLockedPanel();
            }
        }
        else if (showResult == ShowResult.Failed)
        {
            if (!isBallAd)
            {
                Debug.LogWarning("The ad did not finish due to an error.");
                playingSceneManager.LoseTheGame();
                playingSceneCanves.HideAdMenu();
            }
            else
            {
                startSceneCanves.HideLockedPanel();
            }
        }
    }