Initializer.cs 6.2 KB

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