Пример #1
0
    IEnumerator ShowOffer()
    {
        if (ShowOffInvoing)
        {
            yield break;
        }
        ShowOffInvoing = true;
        offerReady     = false;
        offerwallPlacement.RequestContent();
        float time2 = 0.0f;

        while (!offerReady)
        {
            time2 += Time.deltaTime;
            if (time2 > 10.0f)
            {
                offerReady     = false;
                ShowOffInvoing = false;
                yield break;
            }
            yield return(null);
        }
        offerwallPlacement.ShowContent();
        yield return(null);

        ShowOffInvoing = false;
    }
Пример #2
0
    IEnumerator ShowVid()
    {
        Debug.LogError("BannerAd show coroutine");
        if (ShowVidInvoing)
        {
            yield break;
        }
        ShowVidInvoing = true;
        videoReady     = false;
        BannerAd.RequestContent();
        float time = 0.0f;

        while (!videoReady)
        {
            time += Time.deltaTime;
            if (time > 10.0f)
            {
                Debug.LogError("BannerAd show time up");
                videoReady     = false;
                ShowVidInvoing = false;
                yield break;
            }
            yield return(null);
        }
        BannerAd.ShowContent();
        yield return(null);

        ShowVidInvoing = false;
    }
Пример #3
0
 public void TapjoyEvents()
 {
     if (Tapjoy.IsConnected)
     {
         // Create offerwall placement
         if (offerwallPlacement == null)
         {
             offerwallPlacement = TJPlacement.CreatePlacement("unitys");
         }
         if (offerwallPlacement.IsContentReady())
         {
             offerwallPlacement.ShowContent();
         }
         else
         {
             offerwallPlacement.RequestContent();
             offerwallPlacement.ShowContent();
             MyLog.W("Tapjoy offerwallPlacement.IsContentReady false");
             //Code to handle situation where content is not ready goes here
         }
     }
     else
     {
         Tapjoy.Connect(MyConfig.TAPJOY_KEY);
         MyLog.W("Tapjoy.IsConnected false");
     }
 }
Пример #4
0
 public void ShowGameOverPlacement()
 {
     if (gameOver.IsContentReady())
     {
         gameOver.ShowContent();
         gameOver.RequestContent();
     }
 }
Пример #5
0
 public void ShowOnPausePlacement()
 {
     if (onPause.IsContentReady())
     {
         onPause.ShowContent();
         onPause.RequestContent();
     }
 }
Пример #6
0
 public void ShowVideo()
 {
     if (video.IsContentReady())
     {
         video.ShowContent();
         video.RequestContent();
         loadingSpriteUI.enabled = true;
     }
 }
Пример #7
0
 public void ShowGameLaunchPlacement()
 {
     if (gameLaunch.IsContentReady())
     {
         gameLaunch.ShowContent();
         if (Random.Range(0, 5) == 1)
         {
             gameLaunch.RequestContent();
         }
     }
 }
Пример #8
0
        /// <summary>
        /// Loads a specific TapJoy placement if it's not null.
        /// </summary>
        /// <param name="nullMessage">This message will be logged to the console if the placement is null.</param>
        protected virtual void LoadPlacement(TJPlacement placement, string nullMessage = "Attempting to load a null Tapjoy placement.")
        {
            if (!IsInitialized)
            {
                Debug.Log("The TapJoy network is not ready...");
                return;
            }

            if (placement == null)
            {
                Debug.Log(nullMessage);
                return;
            }

            placement.RequestContent();
        }
Пример #9
0
    void OnEnable()
    {
        Debug.Log("C# PlacementExample Enable -- Adding Tapjoy Placement delegates");

        // Placement Delegates
        TJPlacement.OnRequestSuccess  += HandlePlacementRequestSuccess;
        TJPlacement.OnRequestFailure  += HandlePlacementRequestFailure;
        TJPlacement.OnContentReady    += HandlePlacementContentReady;
        TJPlacement.OnContentShow     += HandlePlacementContentShow;
        TJPlacement.OnContentDismiss  += HandlePlacementContentDismiss;
        TJPlacement.OnPurchaseRequest += HandleOnPurchaseRequest;
        TJPlacement.OnRewardRequest   += HandleOnRewardRequest;

        // Tapjoy Placement Video Delegates
        TJPlacement.OnVideoStart    += HandleVideoStart;
        TJPlacement.OnVideoError    += HandleVideoError;
        TJPlacement.OnVideoComplete += HandleVideoComplete;

        // Currency Delegates
        Tapjoy.OnAwardCurrencyResponse             += HandleAwardCurrencyResponse;
        Tapjoy.OnAwardCurrencyResponseFailure      += HandleAwardCurrencyResponseFailure;
        Tapjoy.OnSpendCurrencyResponse             += HandleSpendCurrencyResponse;
        Tapjoy.OnSpendCurrencyResponseFailure      += HandleSpendCurrencyResponseFailure;
        Tapjoy.OnGetCurrencyBalanceResponse        += HandleGetCurrencyBalanceResponse;
        Tapjoy.OnGetCurrencyBalanceResponseFailure += HandleGetCurrencyBalanceResponseFailure;
        Tapjoy.OnEarnedCurrency += HandleEarnedCurrency;

        // Preload direct play placement
        if (directPlayPlacement == null)
        {
            directPlayPlacement = TJPlacement.CreatePlacement("video_unit");
            if (directPlayPlacement != null)
            {
                directPlayPlacement.RequestContent();
            }
        }

        // Create offerwall placement
        if (offerwallPlacement == null)
        {
            offerwallPlacement = TJPlacement.CreatePlacement("offerwall_unit");
        }

        InitUI();
    }
Пример #10
0
    void OnEnable()
    {
        Tapjoy.OnConnectSuccess       += HandleConnectSuccess;
        Tapjoy.OnConnectFailure       += HandleConnectFailure;
        TJPlacement.OnRequestSuccess  += HandlePlacementRequestSuccess;
        TJPlacement.OnRequestFailure  += HandlePlacementRequestFailure;
        TJPlacement.OnContentReady    += HandlePlacementContentReady;
        TJPlacement.OnContentShow     += HandlePlacementContentShow;
        TJPlacement.OnContentDismiss  += HandlePlacementContentDismiss;
        TJPlacement.OnPurchaseRequest += HandleOnPurchaseRequest;
        TJPlacement.OnRewardRequest   += HandleOnRewardRequest;
        // Currency Delegatesåå
        Tapjoy.OnGetCurrencyBalanceResponse += HandleGetCurrencyBalanceResponse;
        Tapjoy.OnEarnedCurrency             += HandleEarnedCurrency;
        if (isInitted)
        {
            if (BannerAd == null)
            {
                BannerAd = TJPlacement.CreatePlacement("Video");
                if (BannerAd != null)
                {
                    BannerAd.RequestContent();
                }
            }

            if (offerwallPlacement == null)
            {
                offerwallPlacement = TJPlacement.CreatePlacement("Wall");
                if (offerwallPlacement != null)
                {
                    offerwallPlacement.RequestContent();
                }
            }
            if (IntterAd == null)
            {
                IntterAd = TJPlacement.CreatePlacement("Pop");
                if (IntterAd != null)
                {
                    IntterAd.RequestContent();
                }
            }
        }
    }
Пример #11
0
    public void HandleConnectSuccess()
    {
        Debug.Log("tapjoy Connect Success ");
        Tapjoy.GetCurrencyBalance();

        isInitted = true;
        if (isInitted)
        {
            if (BannerAd == null)
            {
                BannerAd = TJPlacement.CreatePlacement("Ad_Video");
                if (BannerAd != null)
                {
                    BannerAd.RequestContent();
                }
            }

            if (offerwallPlacement == null)
            {
                offerwallPlacement = TJPlacement.CreatePlacement("Ad_OfferWall");
                if (offerwallPlacement != null)
                {
                    offerwallPlacement.RequestContent();
                }
            }
            if (IntterAd == null)
            {
                IntterAd = TJPlacement.CreatePlacement("InterSticial");
                if (IntterAd != null)
                {
                    IntterAd.RequestContent();
                }
            }
        }
        PS_Plugin.Instance.OnTJInitComplete(true);
    }
Пример #12
0
    void OnGUI()
    {
        Rect  position;
        float yPosition = startY;

        if (inputStyle == null)
        {
            inputStyle          = GUI.skin.textField;
            inputStyle.fontSize = fontSize;
        }

        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button(position, "Show Offerwall"))
        {
            if (offerwallPlacement != null)
            {
                offerwallPlacement.RequestContent();
            }
        }

        yPosition += yPadding;

        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button(position, "Show Direct Play Video Ad"))
        {
            if (directPlayPlacement.IsContentAvailable())
            {
                if (directPlayPlacement.IsContentReady())
                {
                    directPlayPlacement.ShowContent();
                }
                else
                {
                    output = "Direct play video not ready to show.";
                }
            }
            else
            {
                output = "No direct play video to show.";
            }
        }

        yPosition += yPadding;

        // Managed Currency Header
        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label(position, "Managed Currency:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position = new Rect(centerX - (thirdButtonWidth + (thirdButtonWidth / 2)), yPosition, thirdButtonWidth, buttonHeight);
        if (GUI.Button(position, "Get"))
        {
            ResetCurrencyLabel();
            Tapjoy.GetCurrencyBalance();
        }

        position = new Rect(centerX - (thirdButtonWidth / 2), yPosition, thirdButtonWidth, buttonHeight);
        if (GUI.Button(position, "Spend"))
        {
            ResetCurrencyLabel();
            Tapjoy.SpendCurrency(10);
        }

        position = new Rect(centerX + (thirdButtonWidth / 2), yPosition, thirdButtonWidth, buttonHeight);

        if (GUI.Button(position, "Award"))
        {
            ResetCurrencyLabel();
            Tapjoy.AwardCurrency(10);
        }

        yPosition += yPadding;

        // Managed Currency Header
        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label(position, "Content Placement:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position            = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        samplePlacementName = GUI.TextField(position, samplePlacementName, 30, inputStyle);

        yPosition += headerHeight + 10;

        position = new Rect(centerX - halfButtonWidth, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button(position, "Request"))
        {
            // Create a new sample event
            samplePlacement = TJPlacement.CreatePlacement(samplePlacementName);
            if (samplePlacement != null)
            {
                samplePlacement.RequestContent();
                output = "Requesting content for placement: " + samplePlacementName;
            }
        }

        if (!contentIsReadyForPlacement)
        {
            GUI.enabled = false;
        }
        position = new Rect(centerX, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button(position, "Show"))
        {
            samplePlacement.ShowContent();
        }
        if (!contentIsReadyForPlacement)
        {
            GUI.enabled = true;
        }

        yPosition += yPadding;

        // Purchase Header
        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label(position, "Purchase:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button(position, "Purchase"))
        {
            Tapjoy.TrackPurchase("product1", "USD", 0.99);
            output = "Sent track purchase";
        }
        yPosition += yPadding;

        position = new Rect(centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button(position, "Purchase (Campaign)"))
        {
            Tapjoy.TrackPurchase("product1", "USD", 1.99, "TestCampaignID");
            output = "Sent track purchase 2";
        }
        yPosition += yPadding;

        position = new Rect(centerX - halfButtonWidth, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button(position, "Purchase (GooglePlayStore)"))
        {
            Tapjoy.TrackPurchaseInGooglePlayStore(getDummySkuDetails(), getDummyPurchaseData(), getDummyDataSignature(), "TestCampaignID");
            output = "Sent TrackPurchaseInGooglePlayStore";
        }

        position = new Rect(centerX, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button(position, "Purchase (AppleAppStore)"))
        {
            Tapjoy.TrackPurchaseInAppleAppStore("product1", "USD", 1.99, "transactionId", "TestCampaignID");
            output = "Sent TrackPurchaseInAppleAppStore";
        }
        yPosition += yPadding;

        // Display status
        GUI.Label(new Rect(centerX - 200, yPosition, 400, 150), output, outputStyle);
    }
 public void OnCreateDirectPlayTapped()
 {
     // Create direct play placement
     if (directPlayPlacement == null) {
         directPlayPlacement = TJPlacement.CreatePlacement ("video_unit");
         if (directPlayPlacement != null) {
             directPlayPlacement.RequestContent ();
         }
     }
 }
Пример #14
0
 public virtual void OnContentDismiss(TJPlacement p0)
 {
     Log.Debug(TAG, string.Format("OnContentDismiss: {0}", p0.Name));
     UpdateBalance();
     p0.RequestContent();
 }
    void OnEnable()
    {
        Debug.Log ("C# PlacementExample Enable -- Adding Tapjoy Placement delegates");

        // Placement Delegates
        TJPlacement.OnRequestSuccess += HandlePlacementRequestSuccess;
        TJPlacement.OnRequestFailure += HandlePlacementRequestFailure;
        TJPlacement.OnContentReady += HandlePlacementContentReady;
        TJPlacement.OnContentShow += HandlePlacementContentShow;
        TJPlacement.OnContentDismiss += HandlePlacementContentDismiss;
        TJPlacement.OnPurchaseRequest += HandleOnPurchaseRequest;
        TJPlacement.OnRewardRequest += HandleOnRewardRequest;

        // Currency Delegates
        Tapjoy.OnAwardCurrencyResponse += HandleAwardCurrencyResponse;
        Tapjoy.OnAwardCurrencyResponseFailure += HandleAwardCurrencyResponseFailure;
        Tapjoy.OnSpendCurrencyResponse += HandleSpendCurrencyResponse;
        Tapjoy.OnSpendCurrencyResponseFailure += HandleSpendCurrencyResponseFailure;
        Tapjoy.OnGetCurrencyBalanceResponse += HandleGetCurrencyBalanceResponse;
        Tapjoy.OnGetCurrencyBalanceResponseFailure += HandleGetCurrencyBalanceResponseFailure;
        Tapjoy.OnEarnedCurrency += HandleEarnedCurrency;

        // Tapjoy Video Delegates
        Tapjoy.OnVideoStart += HandleVideoStart;
        Tapjoy.OnVideoError += HandleVideoError;
        Tapjoy.OnVideoComplete += HandleVideoComplete;

        // Preload direct play placement
        if (directPlayPlacement == null) {
            directPlayPlacement = TJPlacement.CreatePlacement ("video_unit");
            if (directPlayPlacement != null) {
                directPlayPlacement.RequestContent ();
            }
        }

        // Create offerwall placement
        if (offerwallPlacement == null) {
            offerwallPlacement = TJPlacement.CreatePlacement ("offerwall_unit");
        }

        InitUI ();
    }
    void OnGUI()
    {
        Rect position;
        float yPosition = startY;

        if (inputStyle == null) {
            inputStyle = GUI.skin.textField;
            inputStyle.fontSize = fontSize;
        }

        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button (position, "Show Offerwall")) {
            if (offerwallPlacement != null) {
                offerwallPlacement.RequestContent ();
            }
        }

        yPosition += yPadding;

        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button (position, "Show Direct Play Video Ad")) {
            if (directPlayPlacement.IsContentAvailable ()) {
                if (directPlayPlacement.IsContentReady ()) {
                    directPlayPlacement.ShowContent ();
                } else {
                    output = "Direct play video not ready to show.";
                }
            } else {
                output = "No direct play video to show.";
            }
        }

        yPosition += yPadding;

        // Managed Currency Header
        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label (position, "Managed Currency:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position = new Rect (centerX - (thirdButtonWidth + (thirdButtonWidth / 2)), yPosition, thirdButtonWidth, buttonHeight);
        if (GUI.Button (position, "Get")) {
            ResetCurrencyLabel ();
            Tapjoy.GetCurrencyBalance ();
        }

        position = new Rect (centerX - (thirdButtonWidth / 2), yPosition, thirdButtonWidth, buttonHeight);
        if (GUI.Button (position, "Spend")) {
            ResetCurrencyLabel ();
            Tapjoy.SpendCurrency (10);
        }

        position = new Rect (centerX + (thirdButtonWidth / 2), yPosition, thirdButtonWidth, buttonHeight);

        if (GUI.Button (position, "Award")) {
            ResetCurrencyLabel ();
            Tapjoy.AwardCurrency (10);
        }

        yPosition += yPadding;

        // Managed Currency Header
        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label (position, "Content Placement:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        samplePlacementName = GUI.TextField (position, samplePlacementName, 30, inputStyle);

        yPosition += headerHeight + 10;

        position = new Rect (centerX - halfButtonWidth, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button (position, "Request")) {
            // Create a new sample event
            samplePlacement = TJPlacement.CreatePlacement (samplePlacementName);
            if (samplePlacement != null) {
                samplePlacement.RequestContent ();
                output = "Requesting content for placement: " + samplePlacementName;
            }
        }

        if (!contentIsReadyForPlacement) {
            GUI.enabled = false;
        }
        position = new Rect (centerX, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button (position, "Show")) {
            samplePlacement.ShowContent ();
        }
        if (!contentIsReadyForPlacement) {
            GUI.enabled = true;
        }

        yPosition += yPadding;

        // Purchase Header
        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, headerHeight);
        GUI.Label (position, "Purchase:", headerStyle);

        yPosition += yPadding - (yPadding - headerHeight);

        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button (position, "Purchase")) {
            Tapjoy.TrackPurchase ("product1", "USD", 0.99);
            output = "Sent track purchase";
        }
        yPosition += yPadding;

        position = new Rect (centerX - (buttonWidth / 2), yPosition, buttonWidth, buttonHeight);
        if (GUI.Button (position, "Purchase (Campaign)")) {
            Tapjoy.TrackPurchase ("product1", "USD", 1.99, "TestCampaignID");
            output = "Sent track purchase 2";
        }
        yPosition += yPadding;

        position = new Rect (centerX - halfButtonWidth, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button (position, "Purchase (GooglePlayStore)")) {
            Tapjoy.TrackPurchaseInGooglePlayStore (getDummySkuDetails (), getDummyPurchaseData (), getDummyDataSignature (), "TestCampaignID");
            output = "Sent TrackPurchaseInGooglePlayStore";
        }

        position = new Rect (centerX, yPosition, halfButtonWidth, buttonHeight);
        if (GUI.Button (position, "Purchase (AppleAppStore)")) {
            Tapjoy.TrackPurchaseInAppleAppStore ("product1", "USD", 1.99, "transactionId", "TestCampaignID");
            output = "Sent TrackPurchaseInAppleAppStore";
        }
        yPosition += yPadding;

        // Display status
        GUI.Label (new Rect (centerX - 200, yPosition, 400, 150), output, outputStyle);
    }
    public void HandleOnConnectSuccess()
    {
        TJPlacement tJPlacement = TJPlacement.CreatePlacement("start");

        tJPlacement.RequestContent();
    }