Initializer.cs 9.1 KB

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