Example #1
0
        public void OnClosed(AdAdapter adapter, bool complete)
        {
            if (state == State.SHOWING)
            {
                lastShowTime = DateTime.UtcNow;
                state        = State.READY;

                if (!string.IsNullOrEmpty(adPoint))
                {
                    RecordAdShown(adPoint, lastShowTime);
                }

                if (!rewarded)
                {
                    SmartAds.Instance.DidCloseInterstitialAd();
                }
                else
                {
                    SmartAds.Instance.DidCloseRewardedAd(
                        "{\"reward\":" + (complete ? "true" : "false") + "}");
                }

                ChangeToNextAdapter();
                RequestAd();
            }
        }
Example #2
0
        public void OnLoaded(AdAdapter adapter)
        {
            if (state == State.LOADING)
            {
                state = State.LOADED;

                if (rewarded)
                {
                    SmartAds.Instance.DidLoadRewardedAd();
                }
            }
        }
Example #3
0
        private void ChangeToNextAdapter()
        {
            var index = adapters.IndexOf(adapter);

            if (index == adapters.Count - 1)
            {
                adapter = adapters.First();
            }
            else
            {
                adapter = adapters.ElementAt(index + 1);
            }
        }
Example #4
0
        internal AdAgent(
            bool rewarded,
            int count,
            int adMaxPerSession)
        {
            this.rewarded = rewarded;
            adapters      = Enumerable
                            .Range(0, count)
                            .Select(e => new AdAdapter(rewarded, e))
                            .ToList();
            this.adMaxPerSession = adMaxPerSession;

            adapter = (adapters.Count > 0) ? adapters.First() : null;
            state   = State.READY;
        }
Example #5
0
        public void OnShowing(AdAdapter adapter)
        {
            if (state == State.LOADED)
            {
                state = State.SHOWING;

                shownCount++;
                adapter.shownCount++;

                if (!rewarded)
                {
                    SmartAds.Instance.DidOpenInterstitialAd();
                }
                else
                {
                    SmartAds.Instance.DidOpenRewardedAd(adPoint);
                }
            }
        }