Initializer.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. StartCoroutine(IInitialize());
  67. }
  68. public static void Initialize()
  69. {
  70. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1";
  71. ManaTutorial.TutorialA = ManaData.GetPlayerBool("TutorialA");
  72. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-1";
  73. ManaTutorial.TutorialB_ = ManaData.GetPlayerBool("TutorialB");
  74. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-2";
  75. ManaTutorial.TutorialC_ = ManaData.GetPlayerBool("TutorialC");
  76. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-3";
  77. ManaTutorial.TutorialD_ = ManaData.GetPlayerBool("TutorialD");
  78. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-4";
  79. ManaTutorial.TutorialE_ = ManaData.GetPlayerBool("TutorialE");
  80. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-5";
  81. ManaTutorial.TutorialIndexA = ManaData.GetPlayerInt("TutorialIndexA");
  82. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-6";
  83. ManaTutorial.TutorialIndexB = ManaData.GetPlayerInt("TutorialIndexB");
  84. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-7";
  85. ManaTutorial.TutorialIndexC = ManaData.GetPlayerInt("TutorialIndexC");
  86. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-8";
  87. ManaTutorial.TutorialIndexD = ManaData.GetPlayerInt("TutorialIndexD");
  88. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-9";
  89. ManaTutorial.TutorialIndexE = ManaData.GetPlayerInt("TutorialIndexE");
  90. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-10";
  91. Bundle.LoadAtlasSprites();
  92. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-11";
  93. for (int i = 0; i < RegistList.Count; i++)
  94. {
  95. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 1-12-" + RegistList[i].GetType();
  96. RegistList[i].Instantiate();
  97. }
  98. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 2";
  99. for (int i = 0; i < RegistList.Count; i++)
  100. {
  101. RegistList[i].RegistReference();
  102. }
  103. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 3";
  104. for (int i = 0; i < RegistList.Count; i++)
  105. {
  106. RegistList[i].RegistValueA();
  107. }
  108. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 4";
  109. for (int i = 0; i < RegistList.Count; i++)
  110. {
  111. RegistList[i].RegistValueB();
  112. }
  113. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 5";
  114. for (int i = 0; i < RegistList.Count; i++)
  115. {
  116. RegistList[i].RegistValueC();
  117. RegistList[i].enabled = true;
  118. }
  119. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 6";
  120. Complete = true;
  121. ManaPlayer.InitializeDressRoom();
  122. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 7";
  123. ManaCenter.LoginCallbackInitial(new JsonData());
  124. GameObject.Find("I_Lab").GetComponent<Text>().text = "Error code : 8";
  125. ManaIAP.Initialize();
  126. ManaVisit.Initialize();
  127. ManaReso.Get("I_BlackMask").TweenForCG();
  128. ManaReso.SetActive("I_Lab", false);
  129. ManaReso.Release();
  130. }
  131. public IEnumerator IInitialize()
  132. {
  133. while (!Logo.Complete)
  134. {
  135. yield return null;
  136. }
  137. while (!Bundle.Complete)
  138. {
  139. yield return null;
  140. }
  141. while (ManaData.DamageLock)
  142. {
  143. yield return null;
  144. }
  145. Initialize();
  146. }
  147. }