private void AddClickBehavior(GameObject dummyAd)
        {
            Image[] images  = dummyAd.GetComponentsInChildren <Image>();
            Image   adImage = images[1];
            Button  button  = adImage.GetComponentInChildren <Button>();

            button.onClick.AddListener(() =>
            {
                buttonBehaviour.OpenURL();
            });
            Button[] innerButtons = adImage.GetComponentsInChildren <Button>();

            if (innerButtons.Length < 2)
            {
                Debug.Log("Invalid Prefab");
                return;
            }

            Button closeButton = innerButtons[1];

            closeButton.onClick.AddListener(() =>
            {
                AdBehaviour.DestroyAd(dummyAd);
                prefabAd = null;
                if (OnAdClosed != null)
                {
                    OnAdClosed.Invoke(this, EventArgs.Empty);
                }
                AdBehaviour.ResumeGame();
                if (OnUserEarnedReward != null)
                {
                    OnUserEarnedReward.Invoke(this, GetRewardItem());
                }
            });
        }
Esempio n. 2
0
    private void HandleRewardedAdClosed(object sender, EventArgs args)
    {
        Debug.Log($"HandleRewardedAdClosed event received.");

        commandQueueHandler.SetCommandToQueue(() => OnAdClosed?.Invoke());

        commandQueueHandler.SetCommandToQueue(() => CreateNewRewardedAd());
    }
 public AdShowListener(OnAdShowFailed onAdShowFailed, OnAdImpression onAdImpression, OnAdClicked onAdClicked, OnAdRewarded onAdRewarded, OnAdClosed onAdClosed)
 {
     this.onAdShowFailed = onAdShowFailed;
     this.onAdImpression = onAdImpression;
     this.onAdClicked    = onAdClicked;
     this.onAdRewarded   = onAdRewarded;
     this.onAdClosed     = onAdClosed;
 }
Esempio n. 4
0
    public static void HandleRewardedAdClosed(object sender, EventArgs args)
    {
        CreateAndRequestAd();

        if (OnAdClosed != null)
        {
            OnAdClosed.Invoke();
        }
    }
Esempio n. 5
0
    private static void HandleInterstitialAdClosed(object sender, EventArgs args)
    {
        CreateAndRequestAd();

        if (OnAdClosed != null)
        {
            OnAdClosed.Invoke();
        }
    }
        public void Show()
        {
            Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name);

            OnAdOpening?.Invoke(this, EventArgs.Empty);
            OnAdClosed?.Invoke(this, EventArgs.Empty);
            OnUserEarnedReward?.Invoke(this, new Reward()
            {
                Amount = 1, Type = "dummy reward"
            });
        }
Esempio n. 7
0
        private void AddClickBehavior(GameObject dummyAd)
        {
            Image  myImage = dummyAd.GetComponentInChildren <Image>();
            Button button  = myImage.GetComponentInChildren <Button>();

            button.onClick.AddListener(() => {
                buttonBehaviour.OpenURL();
            });
            Button[] innerButtons = dummyAd.GetComponentsInChildren <Button>();

            innerButtons[1].onClick.AddListener(() =>
            {
                AdBehaviour.DestroyAd(dummyAd);
                if (OnAdClosed != null)
                {
                    OnAdClosed.Invoke(this, new EventArgs());
                }
                AdBehaviour.ResumeGame();
            });
        }