Esempio n. 1
0
    //cyclic test, if ad is available and enable/disable the 'watchAdButton' and generate 'onAdAvailable' event
    IEnumerator testForAdvertisement()
    {
        yield return(null);

        onAdNotAvailable.Invoke();

        yield return(new WaitForSecondsRealtime(0.5f));

        while (true)
        {
                        #if UNITY_ADS
            if ((Advertisement.IsReady(placement) && rewardedAd == true) || (Advertisement.IsReady() && rewardedAd == false))
            {
                if (watchAdButton != null)
                {
                    watchAdButton.interactable = true;
                }

                if (advertisementAvailable == false)
                {
                    advertisementAvailable = true;
                    onAdAvailable.Invoke();
                        #if KINGS_GAME_ASSET_ADS
                    valueIfAvailable.setValues();
                        #endif
                }
                //Debug.Log ("Ad is ready");
            }
            else
            {
                if (watchAdButton != null)
                {
                    watchAdButton.interactable = false;
                }
                //generate 'ad not available' event on first start or if it was available bevore
                if (advertisementAvailable == true || advertisementTested == false)
                {
                    advertisementAvailable = false;
                    advertisementTested    = true;
                    onAdNotAvailable.Invoke();
                        #if KINGS_GAME_ASSET_ADS
                    valueIfNotAvailable.setValues();
                        #endif
                }
                //	Debug.Log ("Ad is NOT ready");
            }
                        #endif


            yield return(new WaitForSecondsRealtime(1f));
        }
    }