Initializer.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. using System;
  5. using System.Xml;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. public class Initializer : MonoBehaviour
  9. {
  10. #region
  11. public static List<Regist> RegistList
  12. {
  13. get
  14. {
  15. if (_RegistList == null)
  16. {
  17. _RegistList = new List<Regist>();
  18. }
  19. return _RegistList;
  20. }
  21. set { _RegistList = value; }
  22. }
  23. public static List<Regist> _RegistList;
  24. public static bool Tutorial;
  25. #endregion
  26. private void Awake()
  27. {
  28. if (Bundle.Instance == null)
  29. {
  30. gameObject.AddScript<Bundle>();
  31. }
  32. if (Auxiliary.Instance == null)
  33. {
  34. gameObject.AddScript<Auxiliary>();
  35. }
  36. gameObject.AddScript<ManaText>();
  37. gameObject.AddScript<ManaReso>();
  38. gameObject.AddScript<ManaAnim>();
  39. gameObject.AddScript<ManaAudio>();
  40. gameObject.AddScript<ManaUI>();
  41. gameObject.AddScript<ManaSign>();
  42. gameObject.AddScript<ManaGarden>();
  43. gameObject.AddScript<ManaData>();
  44. gameObject.AddScript<ManaPlayer>();
  45. gameObject.AddScript<ManaDebug>();
  46. gameObject.AddScript<ManaTutorial>();
  47. gameObject.AddScript<ManaAchieve>();
  48. gameObject.AddScript<ManaMiniGame>();
  49. StartCoroutine(IInitialize());
  50. }
  51. public static void Initialize()
  52. {
  53. Tutorial = Data.PlayerBool("Tutorial");
  54. if (Tutorial)
  55. {
  56. TutorialInitialize();
  57. }
  58. else
  59. {
  60. RegularInitialize();
  61. }
  62. }
  63. public static void TutorialInitialize()
  64. {
  65. for (int i = 0; i < RegistList.Count; i++)
  66. {
  67. RegistList[i].TutorialInstantiate();
  68. }
  69. for (int i = 0; i < RegistList.Count; i++)
  70. {
  71. RegistList[i].TutorialRegistReference();
  72. }
  73. for (int i = 0; i < RegistList.Count; i++)
  74. {
  75. RegistList[i].TutorialRegistValue();
  76. RegistList[i].enabled = true;
  77. }
  78. }
  79. public static void RegularInitialize()
  80. {
  81. for (int i = 0; i < RegistList.Count; i++)
  82. {
  83. RegistList[i].Instantiate();
  84. }
  85. for (int i = 0; i < RegistList.Count; i++)
  86. {
  87. RegistList[i].RegistReference();
  88. }
  89. for (int i = 0; i < RegistList.Count; i++)
  90. {
  91. RegistList[i].RegistValueA();
  92. }
  93. for (int i = 0; i < RegistList.Count; i++)
  94. {
  95. RegistList[i].RegistValueB();
  96. }
  97. for (int i = 0; i < RegistList.Count; i++)
  98. {
  99. RegistList[i].RegistValueC();
  100. RegistList[i].enabled = true;
  101. }
  102. }
  103. public IEnumerator IInitialize()
  104. {
  105. while (Bundle.LoadComplete == false)
  106. {
  107. yield return null;
  108. }
  109. Initialize();
  110. }
  111. }