Inheritance: MonoBehaviour
Esempio 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));
            }
        }
    }
Esempio 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);
    }
    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);
    }
Esempio n. 4
0
 public static void Down()
 {
     if (UnityAdsHelper.isReady())
     {
         UnityAdsHelper.ShowAd();
     }
 }
Esempio 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);
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        m_AdsHelper = GetComponent <UnityAdsHelper>();

        if (!isAdsBannerSet)
        {
            RequestBanner();
        }
    }
Esempio n. 7
0
 public void OnMouseDown()
 {
     if (UnityAdsHelper.isReady())
     {
         UnityAdsHelper.ShowAd();
     }
     Time.timeScale = 1f;
     LedEffect.t    = 2f;
     Application.LoadLevel("Menu");
 }
Esempio 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);
     }
 }
Esempio n. 10
0
 void OnMouseDown()
 {
     if (UnityAdsHelper.isReady())
     {
         Ads.Down();
     }
     else
     {
         Bichapp.SetActive(false);
     }
 }
	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;
	}
Esempio n. 12
0
    void Update()
    {
        if (showAds)
        {
            if (UnityAdsHelper.isReady())
            {
                UnityAdsHelper.Show();
            }

            showAds = false;
        }
    }
Esempio n. 13
0
 private void Awake()
 {
     if (UnityAdsHelper.Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         UnityAdsHelper.Instance = this;
     }
     DontDestroyOnLoad(this);
 }
Esempio n. 14
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else if (Instance != null)
     {
         Destroy(this.gameObject);
     }
 }
Esempio 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);
    }
Esempio n. 16
0
    public void Continue()
    {
        string zoneID = null;

        if (showInterstitialAds && UnityAdsHelper.IsReady(zoneID))
        {
            UnityAdsHelper.ShowAd(zoneID, null, null, null, DoContinue);
        }
        else
        {
            DoContinue();
        }
    }
	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);
	}
Esempio 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);
    }
Esempio 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);
    }
Esempio 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;
        }
    }
Esempio n. 21
0
 private void ShowAd()
 {
     if (!UnityAdsHelper.isSupported)
     {
         return;
     }
     if (!UnityAdsHelper.isInitialized)
     {
         return;
     }
     if (UnityAdsHelper.isShowing)
     {
         return;
     }
     UnityAdsHelper.ShowAd(null, ShowAdFinish);
 }
Esempio 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);
    }
Esempio n. 23
0
    public void ShowAutoAd()
    {
        if (!UnityAdsHelper.isSupported)
        {
            return;
        }
        if (!UnityAdsHelper.isInitialized)
        {
            return;
        }
        if (UnityAdsHelper.isShowing)
        {
            return;
        }

        UnityAdsHelper.ShowAd(null, null);
    }
Esempio 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();
        }
    }
Esempio 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");
    }
Esempio 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
    }
Esempio 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);
    }
Esempio 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);
    }
    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);
        }
    }
Esempio 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;
    }
Esempio 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;
    }
    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>();
    }