示例#1
0
    public override bool?showBanner()
    {
        //Debug.Log("show iad");
        try
        {
            base.showBanner();

            if (Info.IsEditor() || (firstTime && !Setup()))
            {
                //Debug.Log("show return iad");
                return(false);
            }
                        #if UNITY_IPHONE
            //normal
            //AdBinding.createAdBanner(on_bottom);

            // forcar aparecer em baixo
            AdBinding.createAdBanner(true);
            return(null);
                        #else
            return(false);
                        #endif
        }
        catch
        {
            return(Error(API, ERROR_TRY_SHOW_BANNER));
        }
    }
示例#2
0
 public static void showIAdsBanner()
 {
     if (SSAdInitializer.IAdsActiveStaticFlag)
     {
         AdBinding.createAdBanner(true);
     }
 }
示例#3
0
    private bool Setup()
    {
        if (!firstTime)
        {
            return(true);
        }

        firstTime = false;

        try
        {
                        #if UNITY_IPHONE
            Initializate.AddPrefab("AdManager", typeof(AdManager));

            AdBinding.fireHideShowEvents(true);
            AdManager.adViewDidChange += onAdShowed;
                        #endif

            return(true);
        }
        catch
        {
            return(Error(API, ERROR_STARTUP_OBJECT));
        }
    }
示例#4
0
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        displayMainMenu       = false;
        displayGameOver       = false;
        displayMainMenuPaused = false;

        sW                 = Screen.width;
        sH                 = Screen.height;
        buttonWidth        = sW * 0.6f;
        buttonHeight       = sH / 20.0f;
        storeKitController = GetComponent <StoreKitController>();

        // always authenticate at every launch
        GameCenterBinding.authenticateLocalPlayer();
        GameCenterBinding.loadLeaderboardTitles();

        //Get in-app purchase product data
        storeKitController.RequestProductData();

        showAds = true;
        int Ads = EncryptedPlayerPrefs.GetInt("removeadverts");

        if (Ads == 1)
        {
            if (EncryptedPlayerPrefs.CheckEncryption("removeadverts", "int", "1"))
            {
                showAds = false;
            }
        }
        else
        {
            //start loading ad
            AdBinding.initializeInterstitial();
            //start iAd
            AdBinding.createAdBanner(true);
        }

        // hack to detect iPad 3 until Unity adds official support
        this.isPad = (Screen.width >= 1536 || Screen.height >= 1536);
        if (isPad)
        {
            customButtonStyle.fontSize    = 64;
            customHighlightStyle.fontSize = 64;
            customPaddedStyle.fontSize    = 64;
        }

        //keep this object in memory
        DontDestroyOnLoad(transform.gameObject);
    }
示例#5
0
 public void SuccessfulPurchase(StoreKitTransaction transaction)
 {
     if (transaction.productIdentifier == "eu.machten.Bee.extralives")
     {
         EncryptedPlayerPrefs.SetInt("xtralives", 1);
     }
     else if (transaction.productIdentifier == "eu.machten.Bee.10extralives")
     {
         EncryptedPlayerPrefs.SetInt("10xtralives", 1);
     }
     else if (transaction.productIdentifier == "eu.machten.Bee.removeads")
     {
         EncryptedPlayerPrefs.SetInt("removeadverts", 1);
         showAds = false;
         AdBinding.destroyAdBanner();
     }
 }
示例#6
0
    void OnGUI()
    {
        beginColumn();


        if (GUILayout.Button("Create Ad Banner"))
        {
            AdBinding.createAdBanner(true);
        }


        if (GUILayout.Button("Destroy Ad Banner"))
        {
            AdBinding.destroyAdBanner();
        }


        if (isPad)
        {
            if (GUILayout.Button("Initialize Interstitial"))
            {
                bool result = AdBinding.initializeInterstitial();
                Debug.Log("initializeInterstitial: " + result);
            }


            if (GUILayout.Button("Is Interstitial Loaded?"))
            {
                bool result = AdBinding.isInterstitalLoaded();
                Debug.Log("isInterstitalLoaded: " + result);
            }


            if (GUILayout.Button("Show Interstitial"))
            {
                bool result = AdBinding.showInterstitial();
                Debug.Log("showInterstitial: " + result);
            }
        }

        endColumn();
    }
示例#7
0
    public override void hideBanner()
    {
        //Debug.Log("hide iad");

        try
        {
            if (Info.IsEditor() || (firstTime && !Setup()))
            {
                //Debug.Log("return iAd");
                return;
            }
                        #if UNITY_IPHONE
            AdBinding.destroyAdBanner();
            banner_showed = false;
                        #endif
        }
        catch
        {
            Error(API, ERROR_TRY_HIDE_BANNER);
        }
    }
示例#8
0
 // Plays a video with a pre roll ad. Accepted strings are a URL to a video file, the filename of a video in the app bundle or
 // a proper, absolutel path to a video file.
 public static void iAdPlayMovieWithPrerollAd(string videoPathOrUrl)
 {
     AdBinding.playMovieWithPrerollAd(videoPathOrUrl);
 }
示例#9
0
 // Prepares iAd video preroll ads. This should be called at or near app launch time.
 public static void iadPreparePrerollAds()
 {
     AdBinding.preparePrerollAds();
 }
示例#10
0
    //// Sets whether or not adDidShow events should be fired or not
    //public static void iadFireHideShowEvents( bool shouldFire ) {
    //    AdBinding.fireHideShowEvents(shouldFire);
    //}

    //// Starts loading a new interstitial ad.  Returns false when interstitials are not supported.
    //public static bool iadInitializeInterstitial() {
    //    return AdBinding.initializeInterstitial();
    //}

    // Shows an interstitial ad.  Will return false if it isn't loaded.
    public static bool iadShowInterstitial()
    {
        return(AdBinding.showInterstitial());
    }
示例#11
0
 // Checks to see if an interstitial ad is loaded
 public static bool iadIsInterstitalLoaded()
 {
     return(AdBinding.isInterstitalLoaded());
 }
示例#12
0
 // Starts loading a new interstitial ad. Interstitials are available on all iPads and iPhones running iOS 7+.
 public static void iadLoadInterstitial()
 {
     AdBinding.loadInterstitial();
 }
示例#13
0
 // Destroys the ad banner and removes it from view
 public static void iadDestroyAdBanner()
 {
     AdBinding.destroyAdBanner();
 }
示例#14
0
    // Starts up iAd either on the top or bottom of the screen
    //public static void iadCreateAdBanner( bool bannerOnBottom = true ) {
    //    AdBinding.createAdBanner(bannerOnBottom);
    //}

    // Starts up iAd requests and ads the ad view
    public static void iadCreateAdBanner(iAdBannerPosition position, iAdBannerType type = iAdBannerType.Banner)
    {
        AdBinding.createAdBanner(position, type);
    }
示例#15
0
    void OnGUI()
    {
        //PAUSE MENU
        if (displayMainMenu)
        {
            gameOver = false;
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.3f, buttonWidth, buttonHeight), "RESUME GAME", customHighlightStyle))
            {
                displayMainMenu       = false;
                displayMainMenuPaused = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
            }

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.4f, buttonWidth, buttonHeight), "LEADERBOARD", customButtonStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }


            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.5f, buttonWidth, buttonHeight), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "EXTRA LIVES", customButtonStyle))
                {
                    displayExtraLives = true;
                    displayMainMenu   = false;
                }
            }


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.7f, buttonWidth, buttonHeight), "REMOVE ADS", customHighlightStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
                else
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "REMOVE ADS", customButtonStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
            }
        }


        //EXTRA LIVES
        if (displayExtraLives)
        {
            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "BUY EXTRA LIVES", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Survive longer each game by buying extra life options. You can buy an extra 3 or a whopping 10 extra lives!", customPaddedStyle);

                if (GUI.Button(rRect(0.125f, 0.6f, 0.375f, 0.05f), "3 EXTRA LIVES", customHighlightStyle))
                {
                    BuyExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.6f, 0.375f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.125f, 0.65f, 0.375f, 0.05f), "10 EXTRA LIVES", customHighlightStyle))
                {
                    Buy10ExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.65f, 0.375f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //GAME OVER
        if (displayGameOver)
        {
            gameOver = true;

            if (showAds && AdBinding.isInterstitalLoaded())
            {
                AdBinding.destroyAdBanner();
                AdBinding.showInterstitial();
            }

            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);

            GUI.Label(rRect(0.3f, 0.25f, 0.4f, 0.05f), "GAME OVER", customHighlightStyle);
            GUI.Label(rRect(0.3f, 0.3f, 0.4f, 0.05f), "SCORE", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.35f, 0.4f, 0.05f), ((int)Camera.main.GetComponent <beeGUI>().score).ToString(), customButtonStyle);
            GUI.Label(rRect(0.3f, 0.4f, 0.4f, 0.05f), "HIGH", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.45f, 0.4f, 0.05f), EncryptedPlayerPrefs.GetInt("highScoore").ToString(), customButtonStyle);

            if (GUI.Button(rRect(0.3f, 0.52f, 0.4f, 0.05f), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }

            if (GUI.Button(rRect(0.3f, 0.59f, 0.4f, 0.05f), "LEADERBOARD", customHighlightStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }

            float yoffset = 0f;

            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(rRect(0.3f, 0.66f, 0.4f, 0.05f), "EXTRA LIVES", customHighlightStyle))
                {
                    displayExtraLives = true;
                    displayGameOver   = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (showAds == true)
            {
                if (GUI.Button(rRect(0.3f, 0.73f + yoffset, 0.4f, 0.05f), "REMOVE ADS", customHighlightStyle))
                {
                    displayRemoveAds = true;
                    displayGameOver  = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (GUI.Button(rRect(0.3f, 0.80f + yoffset, 0.4f, 0.05f), "TRY AGAIN", customHighlightStyle))
            {
                displayMainMenu = false;
                displayGameOver = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
                if (showAds)
                {
                    AdBinding.createAdBanner(true);
                    AdBinding.initializeInterstitial();
                }
                Application.LoadLevel("game");
            }
        }


        //REMOVE ADS PURCHASE
        if (displayRemoveAds)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "REMOVE ADVERTS", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Have and advert-free experience by purchasing the option below. Then experience uninterrupted gameplay!", customPaddedStyle);


                if (GUI.Button(rRect(0.125f, 0.6f, 0.25f, 0.05f), "NO ADS!", customHighlightStyle))
                {
                    BuyRemoveAds();
                }

                if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.625f, 0.6f, 0.25f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //PROBLEM WITH IN-APP PURCHASE
        if (displayProblem)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "PROBLEM", customHighlightStyle);
            GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "There appears to be a problem in doing that action. Please can you try again later?", customPaddedStyle);


            if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "HOME", customHighlightStyle))
            {
                if (gameOver)
                {
                    displayGameOver = true;
                }
                else
                {
                    displayMainMenu = true;
                }
                displayProblem = false;
            }
        }
    }
示例#16
0
 public void Start()
 {
     // start up iAd and destroy ourself
     AdBinding.createAdBanner(bannerOnBottom);
     Destroy(gameObject);
 }