예제 #1
0
        protected AdManager()
        {
            SGAdConfig sgAdConfig = SGAdConfig.Instant;

            adsAll = new Dictionary <ADCompany, AdBase> ();

            adsVideoController  = new AdShowController(ADType.VIDEO);
            adsFullController   = new AdShowController(ADType.INTERSTITIAL);
            adsBannerController = new AdShowController(ADType.BANNER);

            for (int i = 0; i < sgAdConfig.configs.Count; i++)
            {
                SGAdConfig.SGAdConfigElement config = sgAdConfig.configs [i];
                if (config.isOn)
                {
                    AdBase adbase = CreateAd(config);
                    if (adbase != null)
                    {
                        adsAll.Add(config.adCompany, adbase);
                        adsVideoController.addAd(adbase);
                        adsFullController.addAd(adbase);
                        adsBannerController.addAd(adbase);
                    }
                }
            }

            ShowBanner(BannerVeiwPositoin);
        }
예제 #2
0
            public bool CheckWeight(AdBase adBase1, AdBase adBase2)
            {
                switch (this.adType)
                {
                case ADType.BANNER:
                    return(adBase1.config.weightBanner > adBase1.config.weightBanner);

                case ADType.INTERSTITIAL:
                    return(adBase1.config.weightFull > adBase1.config.weightFull);

                case ADType.VIDEO:
                    return(adBase1.config.weightVideo > adBase1.config.weightVideo);
                }
                return(false);
            }
예제 #3
0
            public bool IsAvailable(AdBase adBase1)
            {
                switch (this.adType)
                {
                case ADType.BANNER:
                    return(adBase1.config.weightBanner > 0);

                case ADType.INTERSTITIAL:
                    return(adBase1.config.weightFull > 0);

                case ADType.VIDEO:
                    return(adBase1.config.weightVideo > 0);
                }
                return(false);
            }
예제 #4
0
 public void addAd(AdBase adBase)
 {
     if (IsAvailable(adBase))
     {
         int insetIndex = 0;
         for (int i = 0; i < adsAll.Count; i++)
         {
             if (CheckWeight(adBase, adsAll [i]))
             {
                 break;
             }
             insetIndex = i + 1;
         }
         adsAll.Insert(insetIndex, adBase);
     }
 }