LoginManager.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using System.Collections.Generic;
  5. public class LoginManager : MonoBehaviour
  6. {
  7. public bool StartNoNumberCompetitions;
  8. public static LoginManager Instance;
  9. public ScreenBase CurScreenCodeEnter;
  10. public ScreenBase WrongLoginConnect;
  11. public ScreenBase WrongNumberPhone;
  12. public ScreenBase CouponBase;
  13. public ScreenBase CouponNumberWronge;
  14. public ScreenBase Login;
  15. public GameObject BackMessageCoupone;
  16. public ScreenBase ScreenCouponeGet;
  17. // public ScreenBase OverCompanyMessage;
  18. public ScreenBase ScreenSendSmsMessages;
  19. public List<UILabel> LabelsAfter28;
  20. public List<UILabel> Labels;
  21. public UIAnchor AnchorGameOverBack;
  22. public List<GameObject> CouponeObjects;
  23. public ScreenBase EnterCode;
  24. public ScreenBase EnterCodeWrong;
  25. public ScreenBase EnterCodeInternetError;
  26. public ScreenBase CouponGetEnterNumber;
  27. public ScreenBase CouponGetEnterNumberWrong;
  28. public ScreenBase CouponGetEnterNumberNoConnect;
  29. public List<ButtonWithTwoStates> ButtonsCoupon;
  30. public bool LoginOpen;
  31. public ScreenBase WrongConnectMessages;
  32. public ScreenBase WrongMessages;
  33. public ScreenBase GreatingMessages;
  34. public ScreenBase StartLevelMessages;
  35. public ScreenBase PopupLifeEndMessages;
  36. public enum StateCountryTelephoneCode
  37. {
  38. Danmark,
  39. Ukraine,
  40. Iceland
  41. }
  42. public StateCountryTelephoneCode CurStateCountryCodePhone;
  43. public bool GetCoupon;
  44. //public int MaxEnterCode;
  45. //public int CountEnterCode = 5;
  46. public DateTime TimeOverCompany;
  47. public bool OVERGAME;
  48. public ScreenBase GameOverVideoAdsLife;
  49. public PowerupsMainControllerCS hPowerupsMainControllerCS;
  50. private ControllerScriptCS hControllerScriptCS;
  51. public ScreenBase TutorDone;
  52. public bool Age;
  53. public ScreenBase OverGameMessage;
  54. public GameObject ThirdEnter;
  55. public GameObject FirstEnter;
  56. public void CouponeClosedWin()
  57. {
  58. //TooltipLastterController.Instance.NotificaionHide();
  59. NGUIMenuScript.Instance.CurStatePopup = NGUIMenuScript.StatesMenuForPopup.None;
  60. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.ChangeLevel);
  61. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.GameOver);
  62. NGUIMenuScript.Instance.toggleHUDGroupState(false, false);
  63. InGameScriptCS.Instance.bGamePaused = true;
  64. DefaultPositionPlayerAndWorld();
  65. PlayerControllerLevels.Instance.UpdatePlayerPosition();
  66. }
  67. public void OnClickOkLevelDone()
  68. {
  69. //if (PlayerPrefs.GetInt("GetCoupon") == 0)
  70. {
  71. TooltipLastterController.Instance.NotificaionHide();
  72. NGUIMenuScript.Instance.CurStatePopup = NGUIMenuScript.StatesMenuForPopup.None;
  73. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.ChangeLevel);
  74. NGUIMenuScript.Instance.toggleHUDGroupState(false, false);
  75. InGameScriptCS.Instance.bGamePaused = true;
  76. DefaultPositionPlayerAndWorld();
  77. PlayerControllerLevels.Instance.UpdatePlayerPosition();
  78. }
  79. //else
  80. //{
  81. // TooltipLastterController.Instance.NotificaionHide();
  82. // CouponGetEnterNumber.Show();
  83. //}
  84. PlayerControllerLevels.Instance.AllDistance = PlayerControllerLevels.Instance.AllDistance + (int)hControllerScriptCS.getCurrentMileage();
  85. PlayerControllerLevels.Instance.AllGifts = PlayerControllerLevels.Instance.AllGifts + (int)hPowerupsMainControllerCS.getCurrencyUnits();
  86. PlayerControllerLevels.Instance.AllPoint = PlayerControllerLevels.Instance.AllPoint + (int)(hControllerScriptCS.getCurrentMileage() + hPowerupsMainControllerCS.getCurrencyUnits() * 3) + TooltipLastterController.Instance.PontWords;
  87. }
  88. public void DefaultPositionPlayerAndWorld()
  89. {
  90. }
  91. public bool OverLogin ()
  92. {
  93. //if ( DateTime.UtcNow.Year == 2016)
  94. //{
  95. // if (DateTime.UtcNow.Hour > 0 && DateTime.UtcNow.Minute > 0 && DateTime.UtcNow.Second > 0)
  96. // {
  97. // Debug.Log("OverLogin 1" );
  98. // return true;
  99. // }
  100. //}
  101. return false;
  102. }
  103. public bool OverCoupone()
  104. {
  105. //if (DateTime.UtcNow.Year == 2016)
  106. //{
  107. // Debug.Log("OverCoupone 1");
  108. // return true;
  109. //}
  110. return false;
  111. }
  112. void Start()
  113. {
  114. Instance = this;
  115. if (PlayerPrefs.GetInt("FirstEnterPage") == 1 && !string.IsNullOrEmpty(RegistrationManager.Instance.CurName) && PlayerPrefs.GetInt("FirstEnter") == 0)
  116. {
  117. ThirdEnter.SetActive(true);
  118. //FirsEnter.Show();
  119. }
  120. if (PlayerPrefs.GetInt("FirstEnterPage") == 0)
  121. {
  122. FirstEnter.SetActive(true);
  123. //FirsEnter.Show();
  124. }
  125. PlayerPrefs.SetInt("Level", 1);
  126. TouchScreenKeyboard.hideInput = true;
  127. StartCoroutine(Init());
  128. hControllerScriptCS = (ControllerScriptCS)GameObject.Find("Player").GetComponent(typeof(ControllerScriptCS));
  129. hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS));
  130. ServerGiftManager.Instance.GetAgeAction(state =>
  131. {
  132. string str = state.ToString();
  133. switch (str)
  134. {
  135. case "1":
  136. //StartCoroutine(EnterNameDialog());
  137. RegistrationManager.Instance.AgeActive = true;
  138. break;
  139. case "0":
  140. break;
  141. }
  142. });
  143. //if (DateTime.UtcNow.Year == 2017)
  144. //{
  145. // Debug.Log("DateTime");
  146. // OverGameMessage.gameObject.SetActive(true);
  147. // OverGameMessage.Show();
  148. // //OVERGAME = true;
  149. //}
  150. //else
  151. //{
  152. // Debug.Log("DateTime 0");
  153. //}
  154. if (OverLogin())
  155. {
  156. foreach (var l in Labels)
  157. {
  158. l.gameObject.SetActive(false);
  159. }
  160. //foreach (var l in LabelsAfter28)
  161. //{
  162. // l.gameObject.SetActive(true);
  163. //}
  164. //Destroy(Login.gameObject);
  165. }
  166. else
  167. {
  168. foreach (var l in Labels)
  169. {
  170. l.gameObject.SetActive(true);
  171. }
  172. //foreach (var l in LabelsAfter28)
  173. //{
  174. // l.gameObject.SetActive(false);
  175. //}
  176. }
  177. if (OverCoupone())
  178. {
  179. foreach (var l in CouponeObjects)
  180. {
  181. l.gameObject.SetActive(false);
  182. }
  183. AnchorGameOverBack.relativeOffset = new Vector2(0.0f,0.08f);
  184. Destroy(CouponGetEnterNumber.gameObject);
  185. }
  186. //Debug.Log(DateTime.UtcNow + " " + DateTime.UtcNow.Date.Month + " " + DateTime.UtcNow.Year +" " + DateTime.UtcNow.Hour);
  187. }
  188. private IEnumerator Init()
  189. {
  190. yield return new WaitForSeconds(1f);
  191. if (WrongLoginConnect != null)
  192. {
  193. yield return new WaitForSeconds(1f);
  194. }
  195. else
  196. {
  197. WrongLoginConnect = (ScreenBase)GameObject.Find("CouponPopupWrongNoConnect1").GetComponent(typeof(ScreenBase));
  198. WrongNumberPhone = (ScreenBase)GameObject.Find("CouponPopupWrongNumber").GetComponent(typeof(ScreenBase));
  199. CouponBase = (ScreenBase)GameObject.Find("CouponPopup").GetComponent(typeof(ScreenBase));
  200. Login = (ScreenBase)GameObject.Find("LoginPopup").GetComponent(typeof(ScreenBase));
  201. GreatingMessages = (ScreenBase)GameObject.Find("MessageGrearting").GetComponent(typeof(ScreenBase));
  202. StartLevelMessages= (ScreenBase)GameObject.Find("StartLevelMessages").GetComponent(typeof(ScreenBase));
  203. EnterCode = (ScreenBase)GameObject.Find("CodeEnter").GetComponent(typeof(ScreenBase));
  204. EnterCodeWrong = (ScreenBase)GameObject.Find("CodeEnterWrong").GetComponent(typeof(ScreenBase));
  205. EnterCodeInternetError = (ScreenBase)GameObject.Find("CodeEnterWrongNoConnect").GetComponent(typeof(ScreenBase));
  206. CouponGetEnterNumber = (ScreenBase)GameObject.Find("CodeEnter").GetComponent(typeof(ScreenBase));
  207. EnterCodeWrong = (ScreenBase)GameObject.Find("CodeEnterWrong").GetComponent(typeof(ScreenBase));
  208. EnterCodeInternetError = (ScreenBase)GameObject.Find("CodeEnterWrongNoConnect").GetComponent(typeof(ScreenBase));
  209. Instance = this;
  210. WrongLoginConnect.Hide();
  211. WrongNumberPhone.Hide();
  212. GreatingMessages.transform.GetComponent<UIPanel>().alpha = 1;
  213. GreatingMessages.Hide();
  214. //CouponGetEnterNumber.Hide();
  215. CouponGetEnterNumberWrong.Hide();
  216. CouponGetEnterNumberNoConnect.Hide();
  217. yield return new WaitForSeconds(1f);
  218. }
  219. }
  220. void OnEnable()
  221. {
  222. //WrongLoginConnect = (ScreenBase)GameObject.Find("CouponPopupWrongNoConnect1").GetComponent(typeof(ScreenBase));
  223. //WrongNumberPhone = (ScreenBase)GameObject.Find("CouponPopupWrongNumber").GetComponent(typeof(ScreenBase));
  224. //CouponBase = (ScreenBase)GameObject.Find("CouponPopup").GetComponent(typeof(ScreenBase));
  225. //Login = (ScreenBase)GameObject.Find("LoginPopup").GetComponent(typeof(ScreenBase));
  226. //EnterCode = (ScreenBase)GameObject.Find("CodeEnter").GetComponent(typeof(ScreenBase));
  227. //EnterCodeWrong = (ScreenBase)GameObject.Find("CodeEnterWrong").GetComponent(typeof(ScreenBase));
  228. //EnterCodeInternetError = (ScreenBase)GameObject.Find("CodeEnterWrongNoConnect").GetComponent(typeof(ScreenBase));
  229. //CouponGetEnterNumber = (ScreenBase)GameObject.Find("CodeEnter").GetComponent(typeof(ScreenBase));
  230. //EnterCodeWrong = (ScreenBase)GameObject.Find("CodeEnterWrong").GetComponent(typeof(ScreenBase));
  231. //EnterCodeInternetError = (ScreenBase)GameObject.Find("CodeEnterWrongNoConnect").GetComponent(typeof(ScreenBase));
  232. //WrongLoginConnect.Hide();
  233. //WrongNumberPhone.Hide();
  234. //CouponGetEnterNumber.Hide();
  235. //CouponGetEnterNumberWrong.Hide();
  236. //CouponGetEnterNumberNoConnect.Hide();
  237. }
  238. //void OnDestroy()
  239. //{
  240. // Destroy(this);
  241. //}
  242. }