示例#1
0
 public void ShowRewardedVideo(Action <bool> callback)
 {
     if (!Advertisement.IsReady())
     {
         HDDebug.Log("AdmobMgr: " + _config.GoogleAds.UnitySkipKey + " not ready");
         if (callback != null)
         {
             callback(false);
         }
         return;
     }
     Advertisement.Show(_config.GoogleAds.UnityRewardKey, new ShowOptions {
         resultCallback = (ShowResult obj) => {
             switch (obj)
             {
             case ShowResult.Finished:
                 if (callback != null)
                 {
                     callback(true);
                 }
                 break;
             }
         }
     });
 }
示例#2
0
 public void CheckAndShowIntersitial(bool forceShow = false)
 {
     HDDebug.Log("ShowIntersitial: " + (_config.Ads.AdsType != null).ToString());
     if (_didInit && !InhouseSDK.getInstance().getIsPro())
     {
         int ratio = UnityEngine.Random.Range(0, 100);
         if (forceShow || ratio < _config.Ads.DisplayFrequencyOfInterstitial)
         {
             foreach (KeyValuePair <string, string> item in _config.Ads.AdsType)
             {
                 if (item.Key == TAG_ADSTYPE_INTERSITIAL)
                 {
                     BaseAds ads = _ads [item.Value];
                     if (ads != null)
                     {
                         ads.ShowIntersitial();
                     }
                     else
                     {
                         HDDebug.Log("AdsMgr: " + item.Key + " not supported");
                     }
                 }
             }
         }
     }
 }
示例#3
0
    public void ReloadBanner(string key, AdPosition pos)
    {
        string adUnitId = key;

        // Create a 320x50 banner at the top of the screen.
        HDDebug.Log("Reload banner: " + (_bannerAd != null).ToString());
        if (_bannerAd != null)
        {
            _bannerAd.Destroy();
        }

        _bannerAd = new BannerView(adUnitId, AdSize.Banner, pos);

        _bannerAd.OnAdLoaded += (object sender, System.EventArgs e) => {
            HDDebug.Log("Banner loaded");
            _bannerAd.Show();
            IsBannerShowing = true;
        };

        _bannerAd.OnAdFailedToLoad += (object sender, AdFailedToLoadEventArgs e) => {
            _bannerAd.Destroy();
            _bannerAd = null;
        };

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the banner with the request.
        _bannerAd.LoadAd(request);
        HDDebug.Log("Banner request");
    }
示例#4
0
 public override void ShowVideoAward(Action <bool> callback)
 {
     if (_manager._didInit)
     {
         if (!Advertisement.IsReady(_config.RewardedKey))
         {
             HDDebug.Log("AdmobMgr: " + _config.RewardedKey + " not ready");
             if (callback != null)
             {
                 callback(false);
             }
             return;
         }
         Advertisement.Show(_config.RewardedKey, new ShowOptions {
             resultCallback = (ShowResult obj) => {
                 switch (obj)
                 {
                 case ShowResult.Finished:
                     if (callback != null)
                     {
                         callback(true);
                     }
                     break;
                 }
             }
         });
     }
 }
示例#5
0
 public void SendScoreToLeaderBoard(string key, int score)
 {
     if (!_didInit)
     {
         return;
     }
     if (!_config.GameCenter.LeaderboardIds.ContainsKey(key))
     {
         HDDebug.Log("GameCenterMgr: " + key + " not exist in plist");
         return;
     }
     Debug.Log("GameCenter: Send score (" + score + ") to Leaderboard: " + _config.GameCenter.LeaderboardIds[key]);
     Social.ReportScore(score, _config.GameCenter.LeaderboardIds[key], SendScoreCallback);
 }
示例#6
0
 public void ShowLeaderBoard(string key)
 {
     if (!_didInit)
     {
         return;
     }
     if (!_config.GameCenter.LeaderboardIds.ContainsKey(key))
     {
         HDDebug.Log("GameCenterMgr: " + key + " not exist in plist");
         return;
     }
     Debug.Log("GameCenter: Show Leaderboard: " + _config.GameCenter.LeaderboardIds[key]);
     GameCenterPlatform.ShowLeaderboardUI(_config.GameCenter.LeaderboardIds[key], TimeScope.AllTime);
 }
示例#7
0
 private void OnSDKNewConfig()
 {
     if (_config.Version == -1)
     {
         return;
     }
     try {
         foreach (var item in _modules)
         {
             HDDebug.Log("InhouseSDK: " + item.Key.ToString() + " onNewConfig");
             item.Value.OnNewConfig();
         }
     } catch (Exception ex) {
         ShowPopup("Error OnSDKNewConfig", ex.ToString(), "Fix lien di", "", "", null);
     }
 }
示例#8
0
    public void ShowSkipVideo(Action <bool> callback)
    {
        if (!Advertisement.IsReady())
        {
            HDDebug.Log("AdmobMgr: " + _config.GoogleAds.UnitySkipKey + " not ready");
            if (callback != null)
            {
                callback(false);
            }
            return;
        }
        int ratio = UnityEngine.Random.Range(0, 100);

        if (ratio < _config.GoogleAds.DisplayFrequencyOfInterstitial)
        {
            Debug.Log("Show Skip video");
            Advertisement.Show(_config.GoogleAds.UnitySkipKey, new ShowOptions {
                resultCallback = (ShowResult obj) => {
                    switch (obj)
                    {
                    case ShowResult.Finished:
                        if (callback != null)
                        {
                            callback(true);
                        }
                        break;

                    case ShowResult.Skipped:
                        if (callback != null)
                        {
                            callback(true);
                        }
                        break;

                    default:
                        if (callback != null)
                        {
                            callback(false);
                        }
                        break;
                    }
                }
            });
        }
    }
示例#9
0
    public override void InitWithConfig(Hashtable data)
    {
        base.InitWithConfig(data);
        if (data == null)
        {
            return;
        }
        data = (Hashtable)data ["PaidAlert"];
        if (data == null)
        {
            return;
        }

        bool      enable    = (bool)data["Enable"];
        Hashtable languages = (Hashtable)data["Languages"];
        int       second    = TypeConvert.ToInt(data["Second"]);
        string    url       = HDUtils.ParseString(data["URL"]);

        if (url == string.Empty)
        {
            return;
        }

        InhouseSDK.Languages outLang = new InhouseSDK.Languages();
        foreach (DictionaryEntry entry in languages)
        {
            InhouseSDK.Language lang    = new InhouseSDK.Language();
            Hashtable           content = (Hashtable)entry.Value;
            lang.Cancel  = HDUtils.ParseString(content ["Cancel"]);
            lang.Key     = HDUtils.ParseString(entry.Key);
            lang.Message = HDUtils.ParseString(content ["Message"]);
            lang.OK      = HDUtils.ParseString(content ["OK"]);
            lang.Title   = HDUtils.ParseString(content ["Title"]);
            outLang.addLanguage(lang);
        }

        _config.PaidAlert.Enable    = enable;
        _config.PaidAlert.Languages = outLang;
        _config.PaidAlert.Second    = second;
        _config.PaidAlert.URL       = url;

        HDDebug.Log("PaidAlertMgr: initWithConfig success");
        _didInit = true;
    }
示例#10
0
 public bool IsVideoAwardedAvaible()
 {
     HDDebug.Log("Check ShowVideoAwarded avaible");
     if (_didInit)
     {
         foreach (KeyValuePair <string, string> item in _config.Ads.AdsType)
         {
             if (item.Key == TAG_ADSTYPE_AWARDED)
             {
                 BaseAds ads = _ads [item.Value];
                 if (ads != null)
                 {
                     return(ads.IsVideoAwardAvaible());
                 }
                 return(false);
             }
         }
     }
     return(false);
 }
示例#11
0
 public void HideBanner()
 {
     if (_didInit && !InhouseSDK.getInstance().getIsPro())
     {
         foreach (KeyValuePair <string, string> item in _config.Ads.AdsType)
         {
             if (item.Key == TAG_ADSTYPE_BANER)
             {
                 BaseAds ads = _ads [item.Value];
                 if (ads != null)
                 {
                     ads.HideBanner();
                 }
                 else
                 {
                     HDDebug.Log("AdsMgr: " + item.Key + " not supported");
                 }
             }
         }
     }
 }
示例#12
0
    private void RequestBanner(string key, AdPosition pos)
    {
        string adUnitId = key;

        // Create a 320x50 banner at the top of the screen.
        if (_bannerAd == null)
        {
            _bannerAd             = new BannerView(adUnitId, AdSize.Banner, pos);
            _bannerAd.OnAdLoaded += (object sender, System.EventArgs e) => {
                HDDebug.Log("Banner loaded");
                _bannerAd.Show();
                IsBannerShowing = true;
                NotificationCenter.getInstance().dispatchEvent(AdsMgr.ADMOB_BANNER_LOADED, null);
            };
        }
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the banner with the request.
        _bannerAd.LoadAd(request);
    }
示例#13
0
 public void ShowVideoAwarded(Action <bool> callback)
 {
     HDDebug.Log("ShowVideoAwarded");
     if (_didInit)
     {
         foreach (KeyValuePair <string, string> item in _config.Ads.AdsType)
         {
             if (item.Key == TAG_ADSTYPE_AWARDED)
             {
                 BaseAds ads = _ads [item.Value];
                 if (ads != null)
                 {
                     ads.ShowVideoAward(callback);
                 }
                 else
                 {
                     HDDebug.Log("AdsMgr: " + item.Key + " not supported");
                 }
             }
         }
     }
 }
示例#14
0
    public void ParseNewData(Hashtable data)
    {
        _config.Version = (int)_checkLoi(data ["Version"], 0, "Version");
//		_config.AppShareText = (string)_checkLoi (data ["AppShareText"], "", "AppShareText");
        _config.AppURL       = (string)_checkLoi(data ["AppURL"], "", "AppURL");
        _config.AppReviewURL = (string)_checkLoi(data ["AppReviewURL"], "", "AppReviewURL");
//		_config.ContactMailAddress = (string)_checkLoi (data ["ContactMailAddress"], "", "ContactMailAddress");
//		_config.ContactMailSubject = (string)_checkLoi (data ["ContactMailSubject"], "", "ContactMailSubject");
        _config.IsProVersion = (bool)_checkLoi(data ["IsProVersion"], false, "IsProVersion");
//		_config.FacebookURL = (string)_checkLoi (data ["FacebookURL"], "", "FacebookURL");


        HDDebug.Log("Module count: " + _modules.Count.ToString());
        foreach (var item in _modules)
        {
            try {
                HDDebug.Log("InhouseSDK: Init with config " + item.Key.ToString());
                item.Value.InitWithConfig(data);
            } catch (Exception ex) {
                ShowPopup("Error initWithConfig", ex.ToString(), "Fix lien di", "", "", null);
            }
        }
    }
示例#15
0
    public void Initialize(string plistUrl, bool useDefault, params Type[] modules)
    {
        if (IsConfigLoaded())
        {
            return;
        }

        PLIST_ONLINE_URL     = plistUrl;
        PLIST_DEFAULT_ENABLE = useDefault;

        foreach (var item in modules)
        {
            if (!item.IsSubclassOf(typeof(BaseMgr)))
            {
                HDDebug.Log("InhouseSDK: " + item.ToString() + "Module type invaid. It must be base of BaseMgr");
                continue;
            }
            BaseMgr manager = (BaseMgr)Activator.CreateInstance(item);
            _modules.Add(item, manager);
        }
        HDDebug.Log("InhouseSDK: Initialize manager complete");
        HDDebug.Log("InhouseSDK: Config loading");
        LoadDataConfig();
    }
示例#16
0
    private void OnSDKReady()
    {
        if (_config.Version == -1)
        {
            return;
        }
        Debug.Log("Inhouse SDK Ready");
        try {
            foreach (var item in _modules)
            {
                HDDebug.Log("InhouseSDK: " + item.Key.ToString() + " onConfigLoadComplete");
                item.Value.OnConfigLoadComplete();
            }

            if (this.InhouseReadyCallback != null)
            {
                this.InhouseReadyCallback();
            }
            NotificationCenter.getInstance().dispatchEvent(InhouseConstant.INHOUSE_READY, null);
        } catch (Exception ex) {
            ShowPopup("Error OnSDKReady", ex.ToString(), "Fix lien di", "", "", null);
        }
        Debug.Log("Device Type: " + getDeviceType().ToString());
    }
示例#17
0
 public override void HideBanner()
 {
     HDDebug.Log("UnityAds: not support Banner Ads");
 }
示例#18
0
 public override void ShowVideoAward(Action <bool> callback)
 {
     HDDebug.Log("AdmobAds: Not support Video Rewarded");
 }