Initializer.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using LitJson;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using System.Xml;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Text;
  10. public class Initializer : MonoBehaviour
  11. {
  12. #region
  13. public static List<Regist> RegistList;
  14. #endregion
  15. private void Start()
  16. {
  17. StartCoroutine(IStart());
  18. }
  19. private IEnumerator IStart()
  20. {
  21. string path;
  22. WWW www;
  23. FileInfo fileInfo = new FileInfo(Application.persistentDataPath + "/PlayerConfig.xml");
  24. if (fileInfo.Exists)
  25. {
  26. if (Application.platform == RuntimePlatform.Android)
  27. {
  28. path = "file://" + Application.persistentDataPath + "/PlayerConfig.xml";
  29. }
  30. else
  31. {
  32. path = "file:///" + Application.persistentDataPath + "/PlayerConfig.xml";
  33. }
  34. www = new WWW(path);
  35. yield return www;
  36. }
  37. else
  38. {
  39. if (Application.platform == RuntimePlatform.Android)
  40. {
  41. path = Application.streamingAssetsPath + "/PlayerConfig.xml";
  42. }
  43. else
  44. {
  45. path = "file:///" + Application.streamingAssetsPath + "/PlayerConfig.xml";
  46. }
  47. www = new WWW(path);
  48. yield return www;
  49. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  50. sw.Write(www.text);
  51. sw.Close();
  52. }
  53. Data.PlayerDoc = new XmlDocument();
  54. Data.PlayerDoc.LoadXml(www.text);
  55. Data.PlayerNode = Data.PlayerDoc.SelectSingleNode("PlayerConfig");
  56. RegistList = new List<Regist>();
  57. gameObject.AddScript<ManaReso>();
  58. gameObject.AddScript<ManaAnim>();
  59. gameObject.AddScript<ManaAudio>();
  60. gameObject.AddScript<ManaUI>();
  61. gameObject.AddScript<ManaData>();
  62. gameObject.AddScript<ManaGarden>();
  63. gameObject.AddScript<ManaDebug>();
  64. gameObject.AddScript<ManaPlayer>();
  65. gameObject.AddScript<ManaMiniGame>();
  66. for (int i = 0; i < RegistList.Count; i++)
  67. {
  68. RegistList[i].RegistReference();
  69. }
  70. for (int i = 0; i < RegistList.Count; i++)
  71. {
  72. RegistList[i].RegistValueA();
  73. }
  74. for (int i = 0; i < RegistList.Count; i++)
  75. {
  76. RegistList[i].RegistValueB();
  77. }
  78. for (int i = 0; i < RegistList.Count; i++)
  79. {
  80. RegistList[i].RegistValueC();
  81. }
  82. }
  83. }