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