UIRaceStart.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using UnityEngine;
  2. using System.Collections;
  3. public class UIRaceStart : MonoBehaviour {
  4. [SerializeField]
  5. private UIButton Ok;
  6. [SerializeField]
  7. private UIButton Cancel;
  8. [SerializeField]
  9. private UILabel Counter;
  10. public GameObject[] CountDown;
  11. //string _bannerAdUnitId = "58af783bbcd54f4a8586dff3b15eb4eb";
  12. //string _bannerAdUnitId = "1a553046db6a4cb2816f1f837c79fa19";
  13. string _bannerAdUnitId = "agltb3B1Yi1pbmNyDAsSBFNpdGUY6tERDA";
  14. internal void Start()
  15. {
  16. Ok.onClick.Add(new EventDelegate(OnOk));
  17. Cancel.onClick.Add(new EventDelegate(OnCancel));
  18. }
  19. private void OnOk()
  20. {
  21. if (!InstructionsHomeButtonHandler.FirstPlay)
  22. {
  23. InGameScriptCS.Instance.launchGame(); //start the gameplay
  24. //NGUIMenuScript.Instance.NGUIMenuScriptEnabled(false);
  25. }
  26. else
  27. {
  28. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.InstructionsMenu);
  29. }
  30. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceStart);
  31. }
  32. private void OnCancel() { }
  33. public void OnShow()
  34. {
  35. if (AdwareRequest.HasAdware)
  36. {
  37. AdwareRequest.Show();
  38. StartCoroutine(EnableOK());
  39. Ok.gameObject.SetActive(false);
  40. }
  41. else
  42. {
  43. OnOk();
  44. }
  45. }
  46. private IEnumerator EnableOK()
  47. {
  48. var cntr = 3;
  49. while (cntr > 0)
  50. {
  51. cntr--;
  52. if (cntr < 0)
  53. {
  54. break;
  55. }
  56. else
  57. {
  58. for (int i = 0; i < 3; i++)
  59. {
  60. CountDown[i].SetActive(i == (cntr));
  61. }
  62. yield return new WaitForSeconds(1f);
  63. }
  64. }
  65. for (int i = 0; i < 3; i++)
  66. {
  67. CountDown[i].SetActive(false);
  68. }
  69. OnOk();
  70. //Ok.gameObject.SetActive(true);
  71. }
  72. }