Initializer.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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 Config
  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. HttpManager.Login(Manager.LoginCallbackInitial);
  38. progress = "4";
  39. HttpManager.MailRequest();
  40. progress = "5";
  41. HttpManager.RankRequest();
  42. progress = "6";
  43. HttpManager.IOSAlipayRequest();
  44. progress = "7";
  45. HttpManager.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<IAPManager>();
  59. progress = "10";
  60. gameObject.AddComponent<VisitManager>();
  61. progress = "11";
  62. gameObject.AddComponent<DebugManager>();
  63. progress = "12";
  64. gameObject.AddScript<Auxiliary>();
  65. progress = "13";
  66. gameObject.AddScript<ConfigManager>();
  67. progress = "14";
  68. gameObject.AddScript<ResourceManager>();
  69. progress = "15";
  70. gameObject.AddScript<TutorialManager>();
  71. progress = "16";
  72. gameObject.AddScript<LanguageManager>();
  73. progress = "17";
  74. gameObject.AddScript<AnimManager>();
  75. progress = "18";
  76. gameObject.AddScript<AudioManager>();
  77. progress = "19";
  78. gameObject.AddScript<AchieveManager>();
  79. progress = "20";
  80. gameObject.AddScript<UIManager>();
  81. progress = "21";
  82. gameObject.AddScript<SignManager>();
  83. progress = "22";
  84. gameObject.AddScript<Manager>();
  85. progress = "23";
  86. gameObject.AddScript<GardenManager>();
  87. progress = "24";
  88. gameObject.AddScript<PlayerManager>();
  89. progress = "25";
  90. gameObject.AddScript<HttpManager>();
  91. progress = "26";
  92. gameObject.AddScript<MiniGameManager>();
  93. progress = "27";
  94. gameObject.AddScript<InfoBoxManager>();
  95. progress = "28";
  96. gameObject.AddScript<SocialManager>();
  97. progress = "29";
  98. gameObject.AddScript<NickNameManager>();
  99. progress = "30";
  100. gameObject.AddScript<SFSManager>();
  101. progress = "31";
  102. gameObject.AddScript<PlazaRoomManager>();
  103. progress = "31-1";
  104. gameObject.AddScript<ChestManager>();
  105. progress = "31-2";
  106. gameObject.AddScript<RobotManager>();
  107. progress = "32";
  108. StartCoroutine(IInitialize());
  109. }
  110. catch (Exception e)
  111. {
  112. GameObject.Find(ObjectLabel.Canvas).GetChild(0).SetActive(true);
  113. GameObject.Find(ObjectLabel.Canvas).GetChild(1).SetActive(true);
  114. GameObject.Find("Text").GetComponent<Text>().text = progress + "\n" + e;
  115. throw new Exception();
  116. }
  117. }
  118. private void InitializeDataEye()
  119. {
  120. if (Application.platform == RuntimePlatform.IPhonePlayer)
  121. {
  122. DataEyeGA.Init("C5790DBD2CFE97BD18C7BE9A95482C05", DataEyeGA.PlatformType.IOS, "Official", "IOS");
  123. }
  124. else if (Application.isMobilePlatform)
  125. {
  126. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.ADR, "Official", "Android");
  127. }
  128. else if (Application.isEditor)
  129. {
  130. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.WP, "Official", "Windows");
  131. }
  132. }
  133. public static void InitializeEntrance()
  134. {
  135. //DelayCall.Call
  136. //(
  137. // 1,
  138. // () =>
  139. // {
  140. if (Instance.CatchException)
  141. {
  142. DebugManager.TryCatch(Initialize, EnableDebugLab);
  143. }
  144. else
  145. {
  146. Initialize();
  147. }
  148. // }
  149. //);
  150. }
  151. public static Text DebugLab;
  152. public static void Initialize()
  153. {
  154. DebugLab = GameObject.Find(ObjectLabel.U_DebugLab).GetComponent<Text>();
  155. DebugLab.text = "Error code : 1";
  156. TutorialManager.NewplayerTutorial = ConfigManager.GetPlayerBool("TutorialA");
  157. DebugLab.text = "Error code : 1-1";
  158. TutorialManager.memoryMinigameTutorial = ConfigManager.GetPlayerBool("TutorialB");
  159. DebugLab.text = "Error code : 1-2";
  160. TutorialManager.visitTutorial = ConfigManager.GetPlayerBool("TutorialC");
  161. DebugLab.text = "Error code : 1-3";
  162. TutorialManager.dressroomTutorial = ConfigManager.GetPlayerBool("TutorialD");
  163. DebugLab.text = "Error code : 1-4";
  164. TutorialManager.findMinigameTutorial = ConfigManager.GetPlayerBool("TutorialE");
  165. DebugLab.text = "Error code : 1-5";
  166. TutorialManager.plazaRoomTutorial = ConfigManager.GetPlayerBool("TutorialPlazaRoom");
  167. DebugLab.text = "Error code : 1-5-1";
  168. TutorialManager.NewplayerTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexA");
  169. DebugLab.text = "Error code : 1-6";
  170. TutorialManager.MemoryMinigameTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexB");
  171. DebugLab.text = "Error code : 1-7";
  172. TutorialManager.VisitTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexC");
  173. DebugLab.text = "Error code : 1-8";
  174. TutorialManager.DressroomTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexD");
  175. DebugLab.text = "Error code : 1-9";
  176. TutorialManager.FindMinigameTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexE");
  177. DebugLab.text = "Error code : 1-10";
  178. TutorialManager.PlazaRoomTutorialIndex = ConfigManager.GetPlayerInt("TutorialIndexPlazaRoom");
  179. DebugLab.text = "Error code : 1-10-1";
  180. Bundle.LoadAtlasSprites();
  181. DebugLab.text = "Error code : 1-11";
  182. for (int i = 0; i < RegistList.Count; i++)
  183. {
  184. DebugLab.text = "Error code : 1-12-" + i;
  185. //Debug.Log(i + " " + RegistList[i].GetType());
  186. RegistList[i].InstantiatePrefabs();
  187. }
  188. DebugLab.text = "Error code : 2";
  189. for (int i = 0; i < RegistList.Count; i++)
  190. {
  191. DebugLab.text = "Error code : 2-" + i;
  192. RegistList[i].RegistReference();
  193. }
  194. DebugLab.text = "Error code : 3";
  195. for (int i = 0; i < RegistList.Count; i++)
  196. {
  197. DebugLab.text = "Error code : 3-" + i;
  198. RegistList[i].FirstInit();
  199. }
  200. DebugLab.text = "Error code : 4";
  201. for (int i = 0; i < RegistList.Count; i++)
  202. {
  203. DebugLab.text = "Error code : 4-" + i;
  204. RegistList[i].SecondInit();
  205. }
  206. DebugLab.text = "Error code : 5";
  207. for (int i = 0; i < RegistList.Count; i++)
  208. {
  209. DebugLab.text = "Error code : 5-" + i;
  210. RegistList[i].ThirdInit();
  211. RegistList[i].enabled = true;
  212. }
  213. DebugLab.text = "Error code : 6";
  214. Complete = true;
  215. if (HttpManager.NotificationReady)
  216. {
  217. ResourceManager.Get(ObjectLabel.C_Notify).TweenForCG();
  218. }
  219. DebugLab.text = "Error code : 7";
  220. PlayerManager.InitializeDressRoom();
  221. DebugLab.text = "Error code : 8";
  222. Manager.LoginCallbackInitial(new JsonData());
  223. //debugLab.text = "Error code : 9";
  224. //SFSManager.GardenSmartFox.Connector.Connect();
  225. DebugLab.text = "Error code : 10";
  226. StringFilter.Init();
  227. DebugLab.text = "Error code : 11";
  228. IAPManager.Initialize();
  229. DebugLab.text = "Error code : 12";
  230. VisitManager.Initialize();
  231. DebugLab.text = "Error code : 13";
  232. SocialManager.InitializeRankPanel();
  233. if (Instance.DebugMode)
  234. {
  235. ActivateGame();
  236. }
  237. else
  238. {
  239. ShowLoadingPanel();
  240. }
  241. }
  242. private static void ShowLoadingPanel()
  243. {
  244. ResourceManager.Get(ObjectLabel.U_Group).TweenForCG();
  245. ResourceManager.Get<CanvasGroup>(ObjectLabel.C_Main).alpha = 0;
  246. Auxiliary.Instance.DelayCall(ActivateGame, 3f);
  247. }
  248. private static void ActivateGame()
  249. {
  250. ResourceManager.Get(ObjectLabel.U_LoadingPanel).TweenForCG();
  251. ResourceManager.Get<CanvasGroup>(ObjectLabel.C_Main).alpha = 1;
  252. AudioManager.MusicTheme.TweenForAudio();
  253. }
  254. public static void EnableDebugLab()
  255. {
  256. ResourceManager.Get<CanvasGroup>(ObjectLabel.U_Group).alpha = 0;
  257. ResourceManager.Get<Text>(ObjectLabel.U_DebugLab).enabled = true;
  258. throw new Exception();
  259. }
  260. public IEnumerator IInitialize()
  261. {
  262. while (!Logo.Complete)
  263. {
  264. yield return null;
  265. }
  266. while (!Bundle.Complete)
  267. {
  268. yield return null;
  269. }
  270. while (ConfigManager.DamageLock)
  271. {
  272. yield return null;
  273. }
  274. InitializeEntrance();
  275. }
  276. }