示例#1
0
 public static void showAdOnRightCondition()
 {
     Debug.Log("ad timed played: " + PlayerPrefs.GetFloat("adTimePlayed"));
     if (PlayerPrefs.GetFloat("adTimePlayed") > 90f)
     {
         ChartboostExample.runAd();
         PlayerPrefs.SetFloat("adTimePlayed", 0f);
     }
 }
示例#2
0
 public static void loadAd()
 {
     if ((PlayerPrefs.GetInt("GameTime") >= 100 || PlayerPrefs.GetInt("adIteration") >= 5))            //&& PlayerPrefs.GetString("ads") != "false") {
     {
         float randomNum = UnityEngine.Random.Range(0f, 100f);
         ChartboostExample.runAd();
         PlayerPrefs.SetInt("adIteration", 0);
         PlayerPrefs.SetInt("GameTime", 0);
         Application.LoadLevel("Scene1");
     }
 }
 void Awake()
 {
     if (mngr == null)
     {
         DontDestroyOnLoad(gameObject);
         mngr = this;
     }
     else if (mngr != this)
     {
         Destroy(gameObject);
     }
 }
示例#4
0
 public void playAdForCoins()
 {
     /*if (Advertisement.IsReady ()) {
      *      Advertisement.Show (null, new ShowOptions {
      *              resultCallback = ShowResult => {
      *                      if(ShowResult == ShowResult.Finished) {
      *                              PlayerPrefs.SetInt ("GameTime", 0);
      *                              PlayerPrefs.SetInt ("adIteration", 0);
      *                              PlayerPrefs.SetInt ("coins", PlayerPrefs.GetInt ("coins") + 100);
      *                              Application.LoadLevel ("ShopMenu");
      *                      }
      *              }
      *      });
      * }*/
     ChartboostExample.runAddCoinsAd();
 }
    // Update is called once per frame
    void Update()
    {
        UpdateScrolling();

        frameCount++;
        if (frameCount > 30)
        {
            // update these periodically and not every frame
            hasInterstitial  = Chartboost.hasInterstitial(CBLocation.Default);
            hasMoreApps      = Chartboost.hasMoreApps(CBLocation.Default);
            hasRewardedVideo = Chartboost.hasRewardedVideo(CBLocation.Default);
            hasInPlay        = Chartboost.hasInPlay(CBLocation.Default);

            frameCount = 0;
        }

        //every 2 games shows an interstitial ad and resets the games played counter
        if (Game_Over_Controller.gameOverCount == 12 && Application.loadedLevel == 3)
        {
            ChartboostExample.ShowAd();
            Debug.Log("hey look at that ad");
            Game_Over_Controller.gameOverCount = 0;
        }
        //I don't remember why I made the counter start at 10, but I did
        if (Game_Over_Controller.gameOverCount == 0 && Application.loadedLevel == 2)
        {
            Debug.Log("Requesting new ad");
            ChartboostExample.CacheAd();
            //reset counter to 10
            Game_Over_Controller.gameOverCount = 10;
        }

        if (Application.loadedLevel == 3 && bannerShown == false)
        {
            Debug.Log("Banner should show");
            bannerShown  = true;
            bannerHidden = false;
        }
        if (Application.loadedLevel == 2 && bannerHidden == false)
        {
            Debug.Log("Banner should hide");
            bannerShown  = false;
            bannerHidden = true;
        }
    }
示例#6
0
 public void runVideoAd()
 {
     ChartboostExample.runAddCoinsAd();
 }