Initializer.cs 6.2 KB

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