Initializer.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. if (Application.platform == RuntimePlatform.IPhonePlayer)
  22. {
  23. DataEyeGA.Init("C5790DBD2CFE97BD18C7BE9A95482C05", DataEyeGA.PlatformType.IOS, "Official", "IOS");
  24. }
  25. else if (Application.isMobilePlatform)
  26. {
  27. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.ADR, "Official", "Android");
  28. }
  29. else if (Application.isEditor)
  30. {
  31. DataEyeGA.Init("ADE884FAAF61A2CB45B02431A70932B8", DataEyeGA.PlatformType.WP, "Official", "Windows");
  32. }
  33. Application.targetFrameRate = 50;
  34. DontDestroyOnLoad(gameObject);
  35. ManaServer.Login(ManaCenter.LoginCallbackInitial);
  36. ManaServer.MailRequest();
  37. ManaServer.RankRequest();
  38. ManaServer.IOSAlipayRequest();
  39. ManaServer.NotificationRequest();
  40. Instance = this;
  41. Transform = transform;
  42. if (DebugMode)
  43. {
  44. Instantiate(DebugModeGo, transform);
  45. }
  46. else
  47. {
  48. gameObject.AddComponent<Bundle>();
  49. }
  50. gameObject.AddComponent<ManaIAP>();
  51. gameObject.AddComponent<ManaVisit>();
  52. gameObject.AddComponent<ManaDebug>();
  53. gameObject.AddScript<Auxiliary>();
  54. gameObject.AddScript<ManaData>();
  55. gameObject.AddScript<ManaReso>();
  56. gameObject.AddScript<ManaTutorial>();
  57. gameObject.AddScript<ManaLan>();
  58. gameObject.AddScript<ManaAnim>();
  59. gameObject.AddScript<ManaAudio>();
  60. gameObject.AddScript<ManaAchieve>();
  61. gameObject.AddScript<ManaUI>();
  62. gameObject.AddScript<ManaSign>();
  63. gameObject.AddScript<ManaCenter>();
  64. gameObject.AddScript<ManaGarden>();
  65. gameObject.AddScript<ManaPlayer>();
  66. gameObject.AddScript<ManaServer>();
  67. gameObject.AddScript<ManaMiniGame>();
  68. gameObject.AddScript<ManaInfo>();
  69. gameObject.AddScript<ManaSocial>();
  70. gameObject.AddScript<ManaNickName>();
  71. gameObject.AddScript<GardenSmartFoxManager>();
  72. StartCoroutine(IInitialize());
  73. }
  74. public static void Initialize()
  75. {
  76. //Debug.Log(Application.persistentDataPath);
  77. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1";
  78. ManaTutorial.TutorialA = ManaData.GetPlayerBool("TutorialA");
  79. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-1";
  80. ManaTutorial.TutorialB_ = ManaData.GetPlayerBool("TutorialB");
  81. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-2";
  82. ManaTutorial.TutorialC_ = ManaData.GetPlayerBool("TutorialC");
  83. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-3";
  84. ManaTutorial.TutorialD_ = ManaData.GetPlayerBool("TutorialD");
  85. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-4";
  86. ManaTutorial.TutorialE_ = ManaData.GetPlayerBool("TutorialE");
  87. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-5";
  88. ManaTutorial.TutorialIndexA = ManaData.GetPlayerInt("TutorialIndexA");
  89. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-6";
  90. ManaTutorial.TutorialIndexB = ManaData.GetPlayerInt("TutorialIndexB");
  91. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-7";
  92. ManaTutorial.TutorialIndexC = ManaData.GetPlayerInt("TutorialIndexC");
  93. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-8";
  94. ManaTutorial.TutorialIndexD = ManaData.GetPlayerInt("TutorialIndexD");
  95. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-9";
  96. ManaTutorial.TutorialIndexE = ManaData.GetPlayerInt("TutorialIndexE");
  97. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-10";
  98. Bundle.LoadAtlasSprites();
  99. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-11";
  100. for (int i = 0; i < RegistList.Count; i++)
  101. {
  102. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-12-" + RegistList[i].GetType();
  103. RegistList[i].Instantiate();
  104. }
  105. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 2";
  106. for (int i = 0; i < RegistList.Count; i++)
  107. {
  108. RegistList[i].RegistReference();
  109. }
  110. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 3";
  111. for (int i = 0; i < RegistList.Count; i++)
  112. {
  113. RegistList[i].RegistValueA();
  114. }
  115. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 4";
  116. for (int i = 0; i < RegistList.Count; i++)
  117. {
  118. RegistList[i].RegistValueB();
  119. }
  120. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 5";
  121. for (int i = 0; i < RegistList.Count; i++)
  122. {
  123. RegistList[i].RegistValueC();
  124. RegistList[i].enabled = true;
  125. }
  126. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 6";
  127. Complete = true;
  128. if (ManaServer.NotificationReady)
  129. {
  130. ManaReso.Get("C_Notify").TweenForCG();
  131. }
  132. ManaPlayer.InitializeDressRoom();
  133. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 7";
  134. ManaCenter.LoginCallbackInitial(new JsonData());
  135. StringFilter.Init();
  136. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 8";
  137. ManaIAP.Initialize();
  138. ManaVisit.Initialize();
  139. ManaSocial.InitializeRankPanel();
  140. ManaReso.Get("I_BlackMask").TweenForCG();
  141. ManaReso.SetActive("I_Lab", false);
  142. ManaReso.Release();
  143. }
  144. public IEnumerator IInitialize()
  145. {
  146. while (!Logo.Complete)
  147. {
  148. yield return null;
  149. }
  150. while (!Bundle.Complete)
  151. {
  152. yield return null;
  153. }
  154. while (ManaData.DamageLock)
  155. {
  156. yield return null;
  157. }
  158. Initialize();
  159. }
  160. }