VideoTimer.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class VideoTimer : MonoBehaviour {
  5. public static VideoTimer Instance;
  6. public UILabel LabelTimer;
  7. public float TimeVideo;
  8. public bool Play;
  9. void Start () {
  10. Instance = this;
  11. }
  12. // Update is called once per frame
  13. void Update () {
  14. if(Play)
  15. {
  16. if(LabelTimer==null)
  17. {
  18. LabelTimer = NGUIMenuScript.Instance.LabelVideoTimer;
  19. }
  20. LabelTimer.gameObject.SetActive(true);
  21. TimeVideo -= Time.deltaTime;
  22. if (TimeVideo <=0 )
  23. {
  24. Play = false;
  25. //Adware.Instance.onFinished();
  26. AdManager.Instance.Active = false;
  27. #if UNITY_EDITOR
  28. Adware.Instance.RequesNextAd();
  29. Adware.Instance.Close();
  30. PlayerPrefs.SetInt("AddLifeStep", 2);
  31. InGameScriptCS.Instance.LifeLost = false;
  32. PlayerPrefs.Save();
  33. SoundManagerCS.Instance.EndVideoAd();
  34. #endif
  35. }
  36. LabelTimer.text = ((int)TimeVideo).ToString();
  37. }
  38. else
  39. {
  40. if (LabelTimer == null)
  41. {
  42. LabelTimer = NGUIMenuScript.Instance.LabelVideoTimer;
  43. }
  44. LabelTimer.gameObject.SetActive(false);
  45. }
  46. }
  47. }