Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
Exemplo n.º 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);
            }
Exemplo n.º 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);
     }
 }