Initializer.cs 9.2 KB

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