Initializer.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 bool Tutorial;
  12. public static List<Regist> RegistList;
  13. #endregion
  14. private void Awake()
  15. {
  16. RegistList = new List<Regist>();
  17. if (Bundle.Instance == null)
  18. {
  19. gameObject.AddScript<Bundle>();
  20. }
  21. if (Auxiliary.Instance == null)
  22. {
  23. gameObject.AddScript<Auxiliary>();
  24. }
  25. gameObject.AddScript<ManaReso>();
  26. gameObject.AddScript<ManaAnim>();
  27. gameObject.AddScript<ManaAudio>();
  28. gameObject.AddScript<ManaText>();
  29. gameObject.AddScript<ManaUI>();
  30. gameObject.AddScript<ManaSign>();
  31. gameObject.AddScript<ManaGarden>();
  32. gameObject.AddScript<ManaData>();
  33. gameObject.AddScript<ManaPlayer>();
  34. gameObject.AddScript<ManaDebug>();
  35. gameObject.AddScript<ManaTutorial>();
  36. gameObject.AddScript<ManaAchieve>();
  37. gameObject.AddScript<ManaMiniGame>();
  38. StartCoroutine(IInitialize());
  39. }
  40. public static void Initialize()
  41. {
  42. Tutorial = Convert.ToBoolean(int.Parse(Data.PlayerNode.SelectSingleNode("Tutorial").Attributes[0].Value));
  43. if (Tutorial)
  44. {
  45. TutorialInitialize();
  46. }
  47. else
  48. {
  49. RegularInitialize();
  50. }
  51. }
  52. public static void TutorialInitialize()
  53. {
  54. for (int i = 0; i < RegistList.Count; i++)
  55. {
  56. RegistList[i].TutorialInstantiate();
  57. RegistList[i].enabled = true;
  58. }
  59. for (int i = 0; i < RegistList.Count; i++)
  60. {
  61. RegistList[i].TutorialRegistReference();
  62. }
  63. for (int i = 0; i < RegistList.Count; i++)
  64. {
  65. RegistList[i].TutorialRegistValue();
  66. }
  67. }
  68. public static void RegularInitialize()
  69. {
  70. for (int i = 0; i < RegistList.Count; i++)
  71. {
  72. RegistList[i].Instantiate();
  73. RegistList[i].enabled = true;
  74. }
  75. for (int i = 0; i < RegistList.Count; i++)
  76. {
  77. RegistList[i].RegistReference();
  78. }
  79. for (int i = 0; i < RegistList.Count; i++)
  80. {
  81. RegistList[i].RegistValueA();
  82. }
  83. for (int i = 0; i < RegistList.Count; i++)
  84. {
  85. RegistList[i].RegistValueB();
  86. }
  87. for (int i = 0; i < RegistList.Count; i++)
  88. {
  89. RegistList[i].RegistValueC();
  90. }
  91. }
  92. public IEnumerator IInitialize()
  93. {
  94. while (Bundle.LoadComplete == false)
  95. {
  96. yield return null;
  97. }
  98. Initialize();
  99. }
  100. }