Inheritance: MonoBehaviour
Exemplo n.º 1
0
    private IEnumerator RefreshInternetConnection()
    {
        float timeCheck = 1.0f;//will check google.com every one seconds
        float t1;
        float t2;

        while (!connected)
        {
            WWW www = new WWW("http://google.com");
            t1 = Time.fixedTime;
            yield return(www);

            if (www.error == null)//if no error
            {
#if UNITY_ANDROID
                Advertisement.Initialize("1415243"); // initialize Unity Ads.
                UnityAdsHelper.Initialize();         // initialize Unity Ads.
#elif UNITY_IOS
                UnityAdsHelper.Initialize();         // initialize Unity Ads.
#endif

                connected = true;

                break;//will end the coroutine
            }
            t2 = Time.fixedTime - t1;
            if (t2 < timeCheck)
            {
                yield return(new WaitForSeconds(timeCheck - t2));
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator Start()
    {
        string zoneName = string.IsNullOrEmpty(zoneID) ? "the default ad placement zone" : zoneID;

        _startTime = Time.timeSinceLevelLoad;
        while (!UnityAdsHelper.isInitialized)
        {
            if (Time.timeSinceLevelLoad - _startTime > timeout)
            {
                Debug.LogWarning("Unity Ads failed to initialize in a timely manner. Ad will not be shown on load.");
                yield break;
            }
            yield return(new WaitForSeconds(_yieldTime));
        }
        _startTime = Time.timeSinceLevelLoad;
        while (!UnityAdsHelper.isReady(zoneID))
        {
            if (Time.timeSinceLevelLoad - _startTime > timeout)
            {
                Debug.LogWarning(string.Format("The process of showing ads on load for {0} has timed out. Ad was not shown.", zoneName));
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log(string.Format("Ads for {0} are available and ready. Showing ad now...", zoneName));
        UnityAdsHelper.ShowAd(zoneID, !disablePause);
    }
Exemplo n.º 3
0
    public void ShowAd()
    {
        if (onFinished != null)
        {
            UnityAdsHelper.onFinished = delegate
            {
                if (cooldownTime > 0)
                {
                    SetCooldownTime(DateTime.UtcNow.AddSeconds(cooldownTime));
                    Debug.Log(string.Format("Cooldown timer set. " +
                                            "Next ad available in {0} seconds.", cooldownTime));
                }

                onFinished.Invoke();
            }
        }
        ;
        if (onSkipped != null)
        {
            UnityAdsHelper.onSkipped = delegate { onSkipped.Invoke(); }
        }
        ;
        if (onFailed != null)
        {
            UnityAdsHelper.onFailed = delegate { onFailed.Invoke(); }
        }
        ;

        UnityAdsHelper.ShowAd(placementId, rewarded);
    }
Exemplo n.º 4
0
 public static void Down()
 {
     if (UnityAdsHelper.isReady())
     {
         UnityAdsHelper.ShowAd();
     }
 }
Exemplo n.º 5
0
    public void OnClickAdsBtn()
    {
        if (!UnityAdsHelper.isSupported)
        {
            return;
        }
        if (!UnityAdsHelper.isInitialized)
        {
            return;
        }
        if (UnityAdsHelper.isShowing)
        {
            return;
        }

        UnityAdsHelper.ShowAd(null, () =>
        {
            GameCore.Instance.MeInfo.Integration += 1;
            UserManager.SyncIntegration2Server();

            AddTip("积分+1");
            MMUI.ShowUserInfo();
        });

        AdsBtn.gameObject.SetActive(false);
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        m_AdsHelper = GetComponent <UnityAdsHelper>();

        if (!isAdsBannerSet)
        {
            RequestBanner();
        }
    }
Exemplo n.º 7
0
 public void OnMouseDown()
 {
     if (UnityAdsHelper.isReady())
     {
         UnityAdsHelper.ShowAd();
     }
     Time.timeScale = 1f;
     LedEffect.t    = 2f;
     Application.LoadLevel("Menu");
 }
Exemplo n.º 8
0
 void OnMouseUpAsButton()
 {
     if (UnityAdsHelper.isReady(zoneID))
     {
         UnityAdsHelper.ShowAd(zoneID, !disablePause);
     }
     else
     {
         Debug.LogWarning("Unable to show ad. Zone is not yet ready.");
     }
 }
 private bool IsReady()
 {
     if (DateTime.Compare(DateTime.UtcNow, _rewardCooldownTime) > 0)
     {
         return(UnityAdsHelper.IsReady(zoneId));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 10
0
 void OnMouseDown()
 {
     if (UnityAdsHelper.isReady())
     {
         Ads.Down();
     }
     else
     {
         Bichapp.SetActive(false);
     }
 }
Exemplo n.º 11
0
	private static UnityAdsHelper GetInstance ()
	{
		if (_instance == null)
		{
			GameObject gO = GameObject.Find("UnityAdsHelper");
			if (gO == null) gO = new GameObject("UnityAdsHelper");

			_instance = gO.GetComponent<UnityAdsHelper>();
			if (_instance == null) _instance = gO.AddComponent<UnityAdsHelper>();
		}
		return _instance;
	}
Exemplo n.º 12
0
    void Update()
    {
        if (showAds)
        {
            if (UnityAdsHelper.isReady())
            {
                UnityAdsHelper.Show();
            }

            showAds = false;
        }
    }
Exemplo n.º 13
0
 private void Awake()
 {
     if (UnityAdsHelper.Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         UnityAdsHelper.Instance = this;
     }
     DontDestroyOnLoad(this);
 }
Exemplo n.º 14
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else if (Instance != null)
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 15
0
    // A return type of IEnumerator allows for the use of yield statements.
    //  For more info, see: http://docs.unity3d.com/ScriptReference/YieldInstruction.html
    IEnumerator Start()
    {
        // Zone name used in debug messages.
        string zoneName = string.IsNullOrEmpty(zoneID) ? "the default ad placement zone" : zoneID;

        // Set a start time for the timeout.
        _startTime = Time.timeSinceLevelLoad;

        // Check to see if Unity Ads is initialized.
        //  If not, wait a second before trying again.
        while (!UnityAdsHelper.isInitialized)
        {
            if (useTimeout && Time.timeSinceLevelLoad - _startTime > timeoutDuration)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to initialize in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", zoneName));

                // Break out of both this loop and the Start method; Unity Ads will not
                //  be shown on load since the wait time exceeded the time limit.
                yield break;
            }

            yield return(new WaitForSeconds(yieldTime));
        }

        Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");

        // Set a start time for the timeout.
        _startTime = Time.timeSinceLevelLoad;

        // Check to see if ads are available and ready to be shown.
        //  If ads are not available, wait before trying again.
        while (!UnityAdsHelper.IsReady(zoneID))
        {
            if (useTimeout && Time.timeSinceLevelLoad - _startTime > timeoutDuration)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to be ready in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", zoneName));

                // Break out of both this loop and the Start method; Unity Ads will not
                //  be shown on load since the wait time exceeded the time limit.
                yield break;
            }

            yield return(new WaitForSeconds(yieldTime));
        }

        Debug.Log(string.Format("Ads for {0} are available and ready. Showing ad now...", zoneName));

        // Now that ads are ready, show an ad campaign.
        UnityAdsHelper.ShowAd(zoneID);
    }
Exemplo n.º 16
0
    public void Continue()
    {
        string zoneID = null;

        if (showInterstitialAds && UnityAdsHelper.IsReady(zoneID))
        {
            UnityAdsHelper.ShowAd(zoneID, null, null, null, DoContinue);
        }
        else
        {
            DoContinue();
        }
    }
Exemplo n.º 17
0
	void Awake ()
	{
		if (_instance == null) _instance = this;
		else if (_instance != this)
		{
			Debug.LogWarning("An instance of UnityAdsHelper already exists. Duplicate will be destroyed.");
			Destroy(this);
		}

		if (!isInitialized && !_isInitializing) Initialize();

		DontDestroyOnLoad(gameObject);
	}
Exemplo n.º 18
0
    void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }
        else if (_instance != this)
        {
            Debug.LogWarning("An instance of UnityAdsHelper already exists. Duplicate will be destroyed.");
            Destroy(this);
        }

        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 19
0
    // A return type of IEnumerator allows for the use of yield statements.
    //  For more info, see: http://docs.unity3d.com/ScriptReference/YieldInstruction.html
    IEnumerator Start()
    {
        // Zone name used in debug messages.
        string zoneName = string.IsNullOrEmpty(zoneID) ? "the default ad placement zone" : zoneID;

        // Set a start time for the timeout.
        _startTime = Time.timeSinceLevelLoad;

        // Check to see if Unity Ads is initialized.
        //  If not, wait a second before trying again.
        while (!UnityAdsHelper.isInitialized)
        {
            if (Time.timeSinceLevelLoad - _startTime > timeout)
            {
                Debug.LogWarning("Unity Ads failed to initialize in a timely manner. Ad will not be shown on load.");

                // Break out of both this loop and the Start method; Unity Ads will not
                //  be shown on load since the wait time exceeded the time limit.
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");

        // Set a start time for the timeout.
        _startTime = Time.timeSinceLevelLoad;

        // Check to see if Unity Ads are available and ready to be shown.
        //  If not, wait a second before trying again.
        while (!UnityAdsHelper.isReady(zoneID))
        {
            if (Time.timeSinceLevelLoad - _startTime > timeout)
            {
                Debug.LogWarning(string.Format("The process of showing ads on load for {0} has timed out. Ad was not shown.", zoneName));

                // Break out of both this loop and the Start method; Unity Ads will not
                //  be shown on load since the wait time exceeded the time limit.
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log(string.Format("Ads for {0} are available and ready. Showing ad now...", zoneName));

        // Show ad after Unity Ads finishes initializing and ads are ready to show.
        UnityAdsHelper.ShowAd(zoneID, !disablePause);
    }
Exemplo n.º 20
0
    public static void CreteUnityAdsHelper()
    {
        UnityAdsHelper helper = GameObject.FindObjectOfType <UnityAdsHelper>() as UnityAdsHelper;
        GameObject     gO     = (helper != null ? helper.gameObject : null);

        if (gO == null)
        {
            gO = new GameObject("UnityAdsHelper");
            gO.AddComponent <UnityAdsHelper>();
        }

        if (gO)
        {
            Selection.activeGameObject = gO;
        }
    }
Exemplo n.º 21
0
 private void ShowAd()
 {
     if (!UnityAdsHelper.isSupported)
     {
         return;
     }
     if (!UnityAdsHelper.isInitialized)
     {
         return;
     }
     if (UnityAdsHelper.isShowing)
     {
         return;
     }
     UnityAdsHelper.ShowAd(null, ShowAdFinish);
 }
Exemplo n.º 22
0
    IEnumerator Start()
    {
        if (!UnityAdsHelper.isSupported)
        {
            yield break;
        }
        else if (!UnityAdsHelper.isInitialized)
        {
            UnityAdsHelper.Initialize();
        }

        string placementName = string.IsNullOrEmpty(placementId) ? "the default ad placement" : placementId;

        _startTime = Time.timeSinceLevelLoad;

        while (!UnityAdsHelper.isInitialized)
        {
            if (initTimeout > 0 && Time.timeSinceLevelLoad - _startTime > initTimeout)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to initialize in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", placementName));
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");

        _startTime = Time.timeSinceLevelLoad;

        while (!UnityAdsHelper.IsReady(placementId))
        {
            if (showTimeout > 0 && Time.timeSinceLevelLoad - _startTime > showTimeout)
            {
                Debug.LogWarning(string.Format("Unity Ads failed to be ready in a timely manner. " +
                                               "An ad for {0} will not be shown on load.", placementName));
                yield break;
            }

            yield return(new WaitForSeconds(_yieldTime));
        }

        Debug.Log(string.Format("Ads for {0} are available and ready.", placementName));

        UnityAdsHelper.ShowAd(placementId);
    }
Exemplo n.º 23
0
    public void ShowAutoAd()
    {
        if (!UnityAdsHelper.isSupported)
        {
            return;
        }
        if (!UnityAdsHelper.isInitialized)
        {
            return;
        }
        if (UnityAdsHelper.isShowing)
        {
            return;
        }

        UnityAdsHelper.ShowAd(null, null);
    }
Exemplo n.º 24
0
    void Start()
    {
        _button = GetComponent <Button>();

        if (_button)
        {
            _button.onClick.AddListener(ShowAd);
        }

        _keyCooldownTime   += name + gameObject.GetInstanceID().ToString();
        _rewardCooldownTime = GetCooldownTime();

        if (!UnityAdsHelper.isInitialized)
        {
            UnityAdsHelper.Initialize();
        }
    }
Exemplo n.º 25
0
    public void Submit()
    {
        string gameId         = null;
        bool   enableTestMode = false;

        if (gameIdField)
        {
            gameId = gameIdField.text;
        }
        if (testModeToggle)
        {
            enableTestMode = testModeToggle.isOn;
        }

        UnityAdsHelper.Initialize(gameId, enableTestMode);
        SceneManager.LoadScene("UnityAdsExample");
    }
Exemplo n.º 26
0
    public void Continue()
    {
#if UNITY_IOS || UNITY_ANDROID
        string zoneID = null;

        if (showInterstitialAds && UnityAdsHelper.IsReady(zoneID))
        {
            UnityAdsHelper.ShowAd(zoneID, DoContinue);
        }
        else
        {
            DoContinue();
        }
#else
        DoContinue();
#endif
    }
Exemplo n.º 27
0
    private static UnityAdsHelper GetInstance()
    {
        if (_instance == null)
        {
            GameObject gO = GameObject.Find("UnityAdsHelper");
            if (gO == null)
            {
                gO = new GameObject("UnityAdsHelper");
            }

            _instance = gO.GetComponent <UnityAdsHelper>();
            if (_instance == null)
            {
                _instance = gO.AddComponent <UnityAdsHelper>();
            }
        }
        return(_instance);
    }
Exemplo n.º 28
0
    private IEnumerator ShowAddWhenReady(E_REWARD _rewardID)
    {
        while (!Advertisement.IsReady("rewardedVideo"))
        {
            Advertisement.Initialize("1415243");
            UnityAdsHelper.Initialize();
            yield return(null);
        }

        var options = (_rewardID == E_REWARD.UPGRADE) ?
                      new ShowOptions {
            resultCallback = OnUpgrade
        } :
        new ShowOptions {
            resultCallback = OnLvlEndCoins
        };

        Advertisement.Show("rewardedVideo", options);
    }
Exemplo n.º 29
0
    void Update()
    {
        if (UnityAdsHelper.isReady(_button.zoneID))
        {
            collider.enabled = true;

            Vector3 rotation = transform.localRotation.eulerAngles;
            rotation += Vector3.up * rotationSpeed * Time.deltaTime;

            transform.localRotation = Quaternion.Euler(rotation);
            transform.localPosition = MoveTowards(_initialPos);
        }
        else
        {
            collider.enabled = false;

            transform.localPosition = MoveTowards(_disabledPos);
        }
    }
Exemplo n.º 30
0
    void OnGUI()
    {
        bool isReady = UnityAdsHelper.isReady(zoneID);
        bool pause   = !disablePause;

        GUI.enabled = isReady;
        if (GUI.Button(new Rect(10, 10, 150, 50), isReady ? "Show Ad" : "Waiting..."))
        {
            Debug.Log(string.Format("Ad Placement zone with ID of {0} is {1}.",
                                    string.IsNullOrEmpty(zoneID) ? "null" : zoneID,
                                    isReady ? "ready" : "not ready"));

            if (isReady)
            {
                UnityAdsHelper.ShowAd(zoneID, pause);
            }
        }
        GUI.enabled = true;
    }
Exemplo n.º 31
0
    void OnGUI()
    {
        bool isReady = UnityAdsHelper.isReady(s2sRedeemZoneID);
        bool pause   = !disablePause;

        GUI.enabled = isReady;
        if (GUI.Button(new Rect(Screen.width - 310, 10, 300, 50), isReady ? "Show Ad With S2S Redeem Callback" : "Waiting..."))
        {
            Debug.Log(string.Format("Ad Placement zone with ID of {0} is {1}. This zone is using S2S Redeem Callback functionality.",
                                    string.IsNullOrEmpty(s2sRedeemZoneID) ? "null" : s2sRedeemZoneID,
                                    isReady ? "ready" : "not ready"));

            if (isReady)
            {
                UnityAdsHelperExt.ShowAd(s2sRedeemZoneID, pause);
            }
        }
        GUI.enabled = true;
    }
Exemplo n.º 32
0
    void Start()
    {
        m_JumpController.SetActive(true);

        m_JumpController.GetComponent <JumpAndMenuScript>().RetryAvailable();
        m_JumpController.GetComponent <JumpAndMenuScript>().PauseAvailable();
        m_JumpController.GetComponent <JumpAndMenuScript>().StartBtnActive(false);
        m_JumpController.GetComponent <JumpAndMenuScript>().RetryAfterFailBtnActive(false);

        m_MenuAnimator = m_MenuPanel.GetComponent <Animator>();
        m_MenuAnimator.SetBool("Hide", true);
        m_MenuAnimator.SetBool("Show", false);

        m_CompleteAnimator = m_CompletePanel.GetComponent <Animator>();

        m_isPlaying = true;
        m_isPause   = false;

        m_AudioSource = GetComponent <AudioSource>();
        AudioClip clip = Resources.Load <AudioClip>("Sounds/Chase WAITING LOOP");

        m_AudioSource.clip = clip;
        m_AudioSource.loop = true;
        m_AudioSource.Play();

        BGM_On_Off(m_BGMOn);
        //EffectSound_On_Off(m_EffectSoundOn);
        m_PlayNumbering++;

        if (!isAdsBannerSet && m_ShowAds)
        {
            RequestBanner();
        }

        m_AdsHelper = GetComponent <UnityAdsHelper>();
    }