Initializer.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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<ManaInfo>();
  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. StartCoroutine(IInitialize());
  102. }
  103. catch (Exception e)
  104. {
  105. GameObject.Find("Canvas").GetChild(0).SetActive(true);
  106. GameObject.Find("Canvas").GetChild(1).SetActive(true);
  107. GameObject.Find("Text").GetComponent<Text>().text = progress + "\n" + e;
  108. throw new Exception();
  109. }
  110. }
  111. private void InitializeDataEye()
  112. {
  113. if (Application.platform == RuntimePlatform.IPhonePlayer)
  114. {
  115. DataEyeGA.Init("C5790DBD2CFE97BD18C7BE9A95482C05", DataEyeGA.PlatformType.IOS, "Official", "IOS");
  116. }
  117. else if (Application.isMobilePlatform)
  118. {
  119. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.ADR, "Official", "Android");
  120. }
  121. else if (Application.isEditor)
  122. {
  123. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.WP, "Official", "Windows");
  124. }
  125. }
  126. public static void InitializeEntrance()
  127. {
  128. if (Instance.DebugMode)
  129. {
  130. Initialize();
  131. }
  132. else
  133. {
  134. ManaDebug.TryCatch(Initialize, EnableDebugLab);
  135. }
  136. }
  137. public static void Initialize()
  138. {
  139. Text debugLab = GameObject.Find("U_DebugLab").GetComponent<Text>();
  140. debugLab.text = "Error code : 1";
  141. ManaTutorial.TutorialA = ManaData.GetPlayerBool("TutorialA");
  142. debugLab.text = "Error code : 1-1";
  143. ManaTutorial.TutorialB_ = ManaData.GetPlayerBool("TutorialB");
  144. debugLab.text = "Error code : 1-2";
  145. ManaTutorial.TutorialC_ = ManaData.GetPlayerBool("TutorialC");
  146. debugLab.text = "Error code : 1-3";
  147. ManaTutorial.TutorialD_ = ManaData.GetPlayerBool("TutorialD");
  148. debugLab.text = "Error code : 1-4";
  149. ManaTutorial.TutorialE_ = ManaData.GetPlayerBool("TutorialE");
  150. debugLab.text = "Error code : 1-5";
  151. ManaTutorial.TutorialIndexA = ManaData.GetPlayerInt("TutorialIndexA");
  152. debugLab.text = "Error code : 1-6";
  153. ManaTutorial.TutorialIndexB = ManaData.GetPlayerInt("TutorialIndexB");
  154. debugLab.text = "Error code : 1-7";
  155. ManaTutorial.TutorialIndexC = ManaData.GetPlayerInt("TutorialIndexC");
  156. debugLab.text = "Error code : 1-8";
  157. ManaTutorial.TutorialIndexD = ManaData.GetPlayerInt("TutorialIndexD");
  158. debugLab.text = "Error code : 1-9";
  159. ManaTutorial.TutorialIndexE = ManaData.GetPlayerInt("TutorialIndexE");
  160. debugLab.text = "Error code : 1-10";
  161. Bundle.LoadAtlasSprites();
  162. debugLab.text = "Error code : 1-11";
  163. for (int i = 0; i < RegistList.Count; i++)
  164. {
  165. debugLab.text = "Error code : 1-12-" + i;
  166. RegistList[i].Instantiate();
  167. }
  168. debugLab.text = "Error code : 2";
  169. for (int i = 0; i < RegistList.Count; i++)
  170. {
  171. debugLab.text = "Error code : 2-" + i;
  172. RegistList[i].RegistReference();
  173. }
  174. debugLab.text = "Error code : 3";
  175. for (int i = 0; i < RegistList.Count; i++)
  176. {
  177. debugLab.text = "Error code : 3-" + i;
  178. RegistList[i].RegistValueA();
  179. }
  180. debugLab.text = "Error code : 4";
  181. for (int i = 0; i < RegistList.Count; i++)
  182. {
  183. debugLab.text = "Error code : 4-" + i;
  184. RegistList[i].RegistValueB();
  185. }
  186. debugLab.text = "Error code : 5";
  187. for (int i = 0; i < RegistList.Count; i++)
  188. {
  189. debugLab.text = "Error code : 5-" + i;
  190. RegistList[i].RegistValueC();
  191. RegistList[i].enabled = true;
  192. }
  193. debugLab.text = "Error code : 6";
  194. Complete = true;
  195. if (ManaServer.NotificationReady)
  196. {
  197. ManaReso.Get("C_Notify").TweenForCG();
  198. }
  199. debugLab.text = "Error code : 7";
  200. ManaPlayer.InitializeDressRoom();
  201. debugLab.text = "Error code : 8";
  202. ManaCenter.LoginCallbackInitial(new JsonData());
  203. debugLab.text = "Error code : 9";
  204. //GardenSmartFoxManager.GardenSmartFox.PlazaRoomManager.SyncClose();
  205. debugLab.text = "Error code : 10";
  206. StringFilter.Init();
  207. debugLab.text = "Error code : 11";
  208. ManaIAP.Initialize();
  209. debugLab.text = "Error code : 12";
  210. ManaVisit.Initialize();
  211. debugLab.text = "Error code : 13";
  212. ManaSocial.InitializeRankPanel();
  213. debugLab.text = "Error code : 14";
  214. ManaReso.Release();
  215. if (Instance.DebugMode)
  216. {
  217. ActivateGame();
  218. }
  219. else
  220. {
  221. ShowLoadingPanel();
  222. }
  223. }
  224. private static void ShowLoadingPanel()
  225. {
  226. ManaReso.Get("U_Group").TweenForCG();
  227. Auxiliary.Instance.DelayCall(ActivateGame, 3f);
  228. }
  229. private static void ActivateGame()
  230. {
  231. ManaReso.Get("U_LoadingPanel").TweenForCG();
  232. ManaAudio.MusicTheme.TweenForAudio();
  233. }
  234. public static void EnableDebugLab()
  235. {
  236. ManaReso.Get<CanvasGroup>("U_Group").alpha = 0;
  237. ManaReso.Get<Text>("U_DebugLab").enabled = true;
  238. throw new Exception();
  239. }
  240. public IEnumerator IInitialize()
  241. {
  242. while (!Logo.Complete)
  243. {
  244. yield return null;
  245. }
  246. while (!Bundle.Complete)
  247. {
  248. yield return null;
  249. }
  250. while (ManaData.DamageLock)
  251. {
  252. yield return null;
  253. }
  254. InitializeEntrance();
  255. }
  256. }