Initializer.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using UnityEngine.EventSystems;
  5. using System;
  6. using System.Xml;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. public class Initializer : MonoBehaviour
  10. {
  11. #region 变量
  12. public bool DebugMode;
  13. public GameObject DebugModeGo;
  14. public static bool Complete;
  15. public static Initializer Instance;
  16. public static Transform Transform;
  17. public static List<Regist> RegistList = new List<Regist>();
  18. #endregion
  19. private void Awake()
  20. {
  21. try
  22. {
  23. InitializeDataEye();
  24. }
  25. catch (Exception)
  26. {
  27. }
  28. string progress = "";
  29. try
  30. {
  31. progress = "1";
  32. Application.targetFrameRate = 50;
  33. progress = "2";
  34. DontDestroyOnLoad(gameObject);
  35. progress = "3";
  36. ManaServer.Login(ManaCenter.LoginCallbackInitial);
  37. progress = "4";
  38. ManaServer.MailRequest();
  39. progress = "5";
  40. ManaServer.RankRequest();
  41. progress = "6";
  42. ManaServer.IOSAlipayRequest();
  43. progress = "7";
  44. ManaServer.NotificationRequest();
  45. Instance = this;
  46. Transform = transform;
  47. progress = "8";
  48. if (DebugMode)
  49. {
  50. Instantiate(DebugModeGo, transform);
  51. }
  52. else
  53. {
  54. gameObject.AddComponent<Bundle>();
  55. }
  56. progress = "9";
  57. gameObject.AddComponent<ManaIAP>();
  58. progress = "10";
  59. gameObject.AddComponent<ManaVisit>();
  60. progress = "11";
  61. gameObject.AddComponent<ManaDebug>();
  62. progress = "12";
  63. gameObject.AddScript<Auxiliary>();
  64. progress = "13";
  65. gameObject.AddScript<ManaData>();
  66. progress = "14";
  67. gameObject.AddScript<ManaReso>();
  68. progress = "15";
  69. gameObject.AddScript<ManaTutorial>();
  70. progress = "16";
  71. gameObject.AddScript<ManaLan>();
  72. progress = "17";
  73. gameObject.AddScript<ManaAnim>();
  74. progress = "18";
  75. gameObject.AddScript<ManaAudio>();
  76. progress = "19";
  77. gameObject.AddScript<ManaAchieve>();
  78. progress = "20";
  79. gameObject.AddScript<ManaUI>();
  80. progress = "21";
  81. gameObject.AddScript<ManaSign>();
  82. progress = "22";
  83. gameObject.AddScript<ManaCenter>();
  84. progress = "23";
  85. gameObject.AddScript<ManaGarden>();
  86. progress = "24";
  87. gameObject.AddScript<ManaPlayer>();
  88. progress = "25";
  89. gameObject.AddScript<ManaServer>();
  90. progress = "26";
  91. gameObject.AddScript<ManaMiniGame>();
  92. progress = "27";
  93. gameObject.AddScript<ManaInfoBox>();
  94. progress = "28";
  95. gameObject.AddScript<ManaSocial>();
  96. progress = "29";
  97. gameObject.AddScript<ManaNickName>();
  98. progress = "30";
  99. gameObject.AddScript<GardenSmartFoxManager>();
  100. progress = "31";
  101. gameObject.AddScript<PlazaRoomMge>();
  102. progress = "32";
  103. StartCoroutine(IInitialize());
  104. }
  105. catch (Exception e)
  106. {
  107. GameObject.Find("Canvas").GetChild(0).SetActive(true);
  108. GameObject.Find("Canvas").GetChild(1).SetActive(true);
  109. GameObject.Find("Text").GetComponent<Text>().text = progress + "\n" + e;
  110. throw new Exception();
  111. }
  112. }
  113. private void InitializeDataEye()
  114. {
  115. if (Application.platform == RuntimePlatform.IPhonePlayer)
  116. {
  117. DataEyeGA.Init("C5790DBD2CFE97BD18C7BE9A95482C05", DataEyeGA.PlatformType.IOS, "Official", "IOS");
  118. }
  119. else if (Application.isMobilePlatform)
  120. {
  121. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.ADR, "Official", "Android");
  122. }
  123. else if (Application.isEditor)
  124. {
  125. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.WP, "Official", "Windows");
  126. }
  127. }
  128. public static void InitializeEntrance()
  129. {
  130. if (Instance.DebugMode)
  131. {
  132. Initialize();
  133. }
  134. else
  135. {
  136. ManaDebug.TryCatch(Initialize, EnableDebugLab);
  137. }
  138. }
  139. public static void Initialize()
  140. {
  141. Text debugLab = GameObject.Find("U_DebugLab").GetComponent<Text>();
  142. debugLab.text = "Error code : 1";
  143. ManaTutorial.TutorialA = ManaData.GetPlayerBool("TutorialA");
  144. debugLab.text = "Error code : 1-1";
  145. ManaTutorial.TutorialB_ = ManaData.GetPlayerBool("TutorialB");
  146. debugLab.text = "Error code : 1-2";
  147. ManaTutorial.TutorialC_ = ManaData.GetPlayerBool("TutorialC");
  148. debugLab.text = "Error code : 1-3";
  149. ManaTutorial.TutorialD_ = ManaData.GetPlayerBool("TutorialD");
  150. debugLab.text = "Error code : 1-4";
  151. ManaTutorial.TutorialE_ = ManaData.GetPlayerBool("TutorialE");
  152. debugLab.text = "Error code : 1-5";
  153. ManaTutorial.TutorialPlazaRoom_ = ManaData.GetPlayerBool("TutorialPlazaRoom");
  154. debugLab.text = "Error code : 1-5-1";
  155. ManaTutorial.TutorialIndexA = ManaData.GetPlayerInt("TutorialIndexA");
  156. debugLab.text = "Error code : 1-6";
  157. ManaTutorial.TutorialIndexB = ManaData.GetPlayerInt("TutorialIndexB");
  158. debugLab.text = "Error code : 1-7";
  159. ManaTutorial.TutorialIndexC = ManaData.GetPlayerInt("TutorialIndexC");
  160. debugLab.text = "Error code : 1-8";
  161. ManaTutorial.TutorialIndexD = ManaData.GetPlayerInt("TutorialIndexD");
  162. debugLab.text = "Error code : 1-9";
  163. ManaTutorial.TutorialIndexE = ManaData.GetPlayerInt("TutorialIndexE");
  164. debugLab.text = "Error code : 1-10";
  165. ManaTutorial.TutorialIndexPlazaRoom = ManaData.GetPlayerInt("TutorialIndexPlazaRoom");
  166. debugLab.text = "Error code : 1-10-1";
  167. Bundle.LoadAtlasSprites();
  168. debugLab.text = "Error code : 1-11";
  169. for (int i = 0; i < RegistList.Count; i++)
  170. {
  171. debugLab.text = "Error code : 1-12-" + i;
  172. RegistList[i].Instantiate();
  173. }
  174. debugLab.text = "Error code : 2";
  175. for (int i = 0; i < RegistList.Count; i++)
  176. {
  177. debugLab.text = "Error code : 2-" + i;
  178. RegistList[i].RegistReference();
  179. }
  180. debugLab.text = "Error code : 3";
  181. for (int i = 0; i < RegistList.Count; i++)
  182. {
  183. debugLab.text = "Error code : 3-" + i;
  184. RegistList[i].RegistValueA();
  185. }
  186. debugLab.text = "Error code : 4";
  187. for (int i = 0; i < RegistList.Count; i++)
  188. {
  189. debugLab.text = "Error code : 4-" + i;
  190. RegistList[i].RegistValueB();
  191. }
  192. debugLab.text = "Error code : 5";
  193. for (int i = 0; i < RegistList.Count; i++)
  194. {
  195. debugLab.text = "Error code : 5-" + i;
  196. RegistList[i].RegistValueC();
  197. RegistList[i].enabled = true;
  198. }
  199. debugLab.text = "Error code : 6";
  200. Complete = true;
  201. if (ManaServer.NotificationReady)
  202. {
  203. ManaReso.Get("C_Notify").TweenForCG();
  204. }
  205. debugLab.text = "Error code : 7";
  206. ManaPlayer.InitializeDressRoom();
  207. debugLab.text = "Error code : 8";
  208. ManaCenter.LoginCallbackInitial(new JsonData());
  209. debugLab.text = "Error code : 9";
  210. //GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.SyncClose();
  211. debugLab.text = "Error code : 10";
  212. StringFilter.Init();
  213. debugLab.text = "Error code : 11";
  214. ManaIAP.Initialize();
  215. debugLab.text = "Error code : 12";
  216. ManaVisit.Initialize();
  217. debugLab.text = "Error code : 13";
  218. ManaSocial.InitializeRankPanel();
  219. debugLab.text = "Error code : 14";
  220. ManaReso.Release();
  221. if (Instance.DebugMode)
  222. {
  223. ActivateGame();
  224. }
  225. else
  226. {
  227. ShowLoadingPanel();
  228. }
  229. }
  230. private static void ShowLoadingPanel()
  231. {
  232. ManaReso.Get("U_Group").TweenForCG();
  233. ManaReso.Get<CanvasGroup>("C_Main").alpha = 0;
  234. Auxiliary.Instance.DelayCall(ActivateGame, 3f);
  235. }
  236. private static void ActivateGame()
  237. {
  238. ManaReso.Get("U_LoadingPanel").TweenForCG();
  239. ManaReso.Get<CanvasGroup>("C_Main").alpha = 1;
  240. ManaAudio.MusicTheme.TweenForAudio();
  241. }
  242. public static void EnableDebugLab()
  243. {
  244. ManaReso.Get<CanvasGroup>("U_Group").alpha = 0;
  245. ManaReso.Get<Text>("U_DebugLab").enabled = true;
  246. throw new Exception();
  247. }
  248. public IEnumerator IInitialize()
  249. {
  250. while (!Logo.Complete)
  251. {
  252. yield return null;
  253. }
  254. while (!Bundle.Complete)
  255. {
  256. yield return null;
  257. }
  258. while (ManaData.DamageLock)
  259. {
  260. yield return null;
  261. }
  262. InitializeEntrance();
  263. }
  264. }