Beispiel #1
0
    public void SetInPlayAd(CachedInplay inplay)       //call from ShowInPlayAd & after click the inplayad.
    {
        if (inplay != null)
        {
            AdMob.destroyBanner();              //inplay광고로 대체됨.
            if (mInplayAd != null)
            {
                GameObject.Destroy(mInplayAd);
                mInplayAd = null;
            }

            mInplayAd = (GameObject)Instantiate(inPlayAd, Vector3.zero, Quaternion.identity);
            mInplayAd.transform.parent = inPlayAdSpawnPoint;
            mInplayAd.GetComponent <InPlayAd>().SetInplayData(inplay);
            inplay.Show();
        }
        else
        {
            if (mInplayAd != null)
            {
                GameObject.Destroy(mInplayAd);
                mInplayAd = null;
                ShowBanner();
            }
        }
    }
Beispiel #2
0
 public static void Click(CachedInplay inplay)
 {
     if (inplay != null && inplay.package != null &&
         !_clickedPackages.Contains(inplay.package))
     {
         _clickedPackages.Add(inplay.package);
     }
 }
Beispiel #3
0
 public void SetInplayData(CachedInplay inplay)
 {
     mInplay = inplay;
     transform.localPosition = Vector3.zero;
     transform.localScale    = new Vector3(1f, 1f, 1f);
     mIcon.mainTexture       = inplay.icon;
     mLogo.mainTexture       = inplay.logo;
     inplay.Show();
     GAManager.Instance.GAInplayEvent("display");
 }
Beispiel #4
0
 private void ShowInPlayAd()
 {
     if (!SaveManager.GetRemoveAdsPurchased())
     {
         if (Inplay.IsCached())
         {
             CachedInplay inplay = Inplay.Get();
             SetInPlayAd(inplay);
         }
     }
 }
Beispiel #5
0
    public static CachedInplay Get()
    {
        if (!Config.GetBool(CONFIG_INPLAY_SHOW, false))
        {
            return(null);
        }
        if (UnityEngine.Random.Range(0f, 1f) >= Config.GetFloat(CONFIG_INPLAY_RATIO, 1f))
        {
            return(null);
        }

        CachedInplay inplay = _cachedInplay;

        _cachedInplay = null;

        return(inplay);
    }
Beispiel #6
0
    public static bool Cache()
    {
        if (!Config.GetBool(CONFIG_INPLAY_SHOW, false))
        {
            return(false);
        }
        // 현재 캐싱이 시도되고 있거나 이미 완료된 오브젝트가 없다면
        // 캐싱을 시도한다.
        if (!_busy && _cachedInplay == null)
        {
            // 준비하고있는 Inplay 제거
            _prepareInplay = null;

            PromotionApp promotion = SelectPromotionApp();
            if (promotion != null)
            {
                _prepareInplay = new CachedInplay(promotion.package, promotion.name, promotion.iconId, promotion.logoId, promotion.url);
                return(true);
            }
        }
        return(false);
    }
Beispiel #7
0
    IEnumerator DownloadImages()
    {
        CachedInplay inplay = _prepareInplay;

        if (inplay == null)
        {
            _busy = false;
            yield break;
        }

        if (!string.IsNullOrEmpty(inplay.iconUrl))
        {
            Texture2D texture = _cache.GetTexture(inplay.iconUrl);
            if (texture != null)
            {
                inplay.icon = texture;
            }
            else
            {
                Web web = new Web(inplay.iconUrl);
                yield return(StartCoroutine(web.Request(this)));

                if (web.Result.texture != null && web.Result.error == null)
                {
                    inplay.icon = web.Result.texture;
                    _cache.Put(inplay.iconUrl, web.Result.texture);
                }
                else
                {
                    _busy = false;
                    if (OnCompleteCache != null)
                    {
                        OnCompleteCache(false);
                    }

                    yield break;
                }
            }
        }

        if (!string.IsNullOrEmpty(inplay.logoUrl))
        {
            Texture2D texture = _cache.GetTexture(inplay.logoUrl);
            if (texture != null)
            {
                inplay.logo = texture;
            }
            else
            {
                Web web = new Web(inplay.logoUrl);
                yield return(StartCoroutine(web.Request(this)));

                if (web.Result.texture != null && web.Result.error == null)
                {
                    inplay.logo = web.Result.texture;
                    _cache.Put(inplay.logoUrl, web.Result.texture);
                }
                else
                {
                    _busy = false;
                    if (OnCompleteCache != null)
                    {
                        OnCompleteCache(false);
                    }

                    yield break;
                }
            }
        }

        if (_prepareInplay == inplay)
        {
            _cachedInplay  = inplay;
            _prepareInplay = null;

            _busy = false;

            if (OnCompleteCache != null)
            {
                OnCompleteCache(true);
            }
        }
    }