예제 #1
0
        public override void HideAd()
        {
            if (!m_IsBannerShow)
            {
                return;
            }

            m_IsBannerShow = false;
            if (m_CurrentHandler != null)
            {
                m_CurrentHandler.HideAd();
                m_CurrentHandler      = null;
                m_AlreadyShowDuration = Time.realtimeSinceStartup - m_RefreshTime;
                m_RefreshTime         = -1;
            }

            if (m_RefreshTickTimer > 0)
            {
                Timer.S.Cancel(m_RefreshTickTimer);
                m_RefreshTickTimer = -1;
            }

            if (m_CheckTickTimer > 0)
            {
                Timer.S.Cancel(m_CheckTickTimer);
                m_CheckTickTimer = -1;
            }
        }
예제 #2
0
파일: AdsMgr.cs 프로젝트: moto2002/Fish
        public AdHandler CreateAdHandler(TDAdConfig data)
        {
            if (string.IsNullOrEmpty(data.unitID))
            {
                return(null);
            }

            if (data.ecpm <= -100000)
            {
                return(null);
            }

            if (m_AdHandlerMap.ContainsKey(data.id))
            {
                return(null);
            }

            IAdAdapter adAdapter = GetAdAdapter(data.adPlatform);

            if (adAdapter == null)
            {
                Log.e("Not Find AdAdapter For Ad:" + data.id);
                return(null);
            }

            AdHandler result = null;

            switch (data.adType)
            {
            case AdType.Banner:
                result = adAdapter.CreateBannerHandler();
                break;

            case AdType.Interstitial:
                result = adAdapter.CreateInterstitialHandler();
                break;

            case AdType.NativeAD:
                result = adAdapter.CreateNativeAdHandler();
                break;

            case AdType.RewardedVideo:
                result = adAdapter.CreateRewardVideoHandler();
                break;

            default:
                break;
            }

            if (result != null)
            {
                result.SetAdConfig(data);
            }

            m_AdHandlerMap.Add(data.id, result);

            return(result);
        }
예제 #3
0
        protected void SelectAd2Show()
        {
            AdHandler next = null;

            for (int i = 0; i < m_AdHandler.Count; ++i)
            {
                if (!m_AdHandler[i].isAdPlatformEnable)
                {
                    continue;
                }

                if (m_AdHandler[i].adState != AdState.Failed)
                {
                    next = m_AdHandler[i];
                    break;
                }
            }

            if (next != m_CurrentHandler)
            {
                if (m_CurrentHandler != null)
                {
                    m_CurrentHandler.HideAd();
                }

                m_CurrentHandler = next;

                m_AlreadyShowDuration = 0;
                if (m_CurrentHandler != null)
                {
                    m_CurrentHandler.PreLoadAd();
                    m_CurrentHandler.SyncAdPosition();
                    m_RefreshTime = Time.realtimeSinceStartup;
                    m_CurrentHandler.ShowAd();
                    m_CurrentHandler.RefreshAd();

                    StartCheckTimeTick();
                }
            }
            else
            {
                if (m_CurrentHandler == null)
                {
                    return;
                }

                float showDuration = m_AlreadyShowDuration;
                if (m_RefreshTime > 0)
                {
                    showDuration += Time.realtimeSinceStartup - m_RefreshTime;
                }

                if (!m_IsBannerShow)
                {
                    m_CurrentHandler.ShowAd();
                }

                if (showDuration >= REFRESH_DURATION)
                {
                    m_CurrentHandler.RefreshAd();
                    m_RefreshTime = Time.realtimeSinceStartup;
                    StartCheckTimeTick();
                }
            }
        }
예제 #4
0
 protected int AdHandlerSorter(AdHandler a, AdHandler b)
 {
     return(b.adConfig.ecpm - a.adConfig.ecpm);
 }