ManaData.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. using LitJson;
  2. using UnityEngine;
  3. using System;
  4. using System.IO;
  5. using System.Xml;
  6. using System.Text;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Security.Cryptography;
  10. public class ManaData : Regist
  11. {
  12. #region 变量
  13. public static XmlNode PlayerNode
  14. {
  15. get
  16. {
  17. if (PlayerNode_ == null)
  18. {
  19. PlayerNode_ = PlayerDoc.SelectSingleNode("PlayerConfig");
  20. }
  21. return PlayerNode_;
  22. }
  23. set { PlayerNode_ = value; }
  24. }
  25. public static XmlDocument PlayerDoc
  26. {
  27. get
  28. {
  29. if (PlayerDoc_ == null)
  30. {
  31. int defaultVersion;
  32. int nativeVersion;
  33. XmlNode node;
  34. XmlDocument nativeDoc = new XmlDocument();
  35. string configPath = Application.persistentDataPath + "/PlayerConfig.xml";
  36. if (File.Exists(configPath))
  37. {
  38. StreamReader sr = new StreamReader(configPath);
  39. nativeDoc.LoadXml(sr.ReadToEnd());
  40. sr.Close();
  41. Auxiliary.DecryptXml(nativeDoc);
  42. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  43. DefaultDoc.LoadXml(textAsset.text);
  44. defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  45. node = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version");
  46. if (node == null)
  47. {
  48. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  49. sw.Write(DefaultDoc.OuterXml);
  50. sw.Close();
  51. PlayerDoc_ = DefaultDoc;
  52. }
  53. else
  54. {
  55. nativeVersion = int.Parse(node.Attributes[0].Value);
  56. if (nativeVersion < defaultVersion)
  57. {
  58. PlayerDoc_ = MergeXML(nativeVersion, nativeDoc, DefaultDoc);
  59. }
  60. else if (nativeVersion > defaultVersion)
  61. {
  62. PlayerDoc_ = DefaultDoc;
  63. }
  64. else
  65. {
  66. byte[] bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
  67. MD5 md5 = new MD5CryptoServiceProvider();
  68. if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
  69. {
  70. Debug.LogWarning("Download Archive");
  71. ManaDebug.Log("Download Archive");
  72. DamageLock = true;
  73. DownloadLock = false;
  74. return null;
  75. }
  76. PlayerDoc_ = nativeDoc;
  77. }
  78. }
  79. }
  80. else
  81. {
  82. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  83. DefaultDoc.LoadXml(textAsset.text);
  84. Debug.LogWarning("Download Archive");
  85. ManaDebug.Log("Download Archive");
  86. DamageLock = true;
  87. DownloadLock = false;
  88. return null;
  89. }
  90. }
  91. return PlayerDoc_;
  92. }
  93. set { PlayerDoc_ = value; }
  94. }
  95. public static XmlNode PlayerNode_;
  96. public static XmlDocument PlayerDoc_;
  97. public static float Timer;
  98. public static bool DamageLock;
  99. public static bool DownloadLock;
  100. public static XmlDocument DefaultDoc = new XmlDocument();
  101. #endregion
  102. public void Update()
  103. {
  104. if (DamageLock)
  105. {
  106. Timer += Time.fixedDeltaTime;
  107. if (Timer >= 10)
  108. {
  109. DamageLock = false;
  110. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  111. PlayerDoc_ = new XmlDocument();
  112. PlayerDoc_.LoadXml(textAsset.text);
  113. return;
  114. }
  115. }
  116. if (!DownloadLock)
  117. {
  118. if (ManaServer.ID != "Default")
  119. {
  120. DownloadLock = true;
  121. ManaServer.Download(ManaServer.ID, RecoveXml);
  122. }
  123. }
  124. }
  125. public override bool RegistImmed()
  126. {
  127. if (base.RegistImmed())
  128. {
  129. return true;
  130. }
  131. enabled = true;
  132. return false;
  133. }
  134. public static void SaveXml()
  135. {
  136. if (Initializer.Complete)
  137. {
  138. byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
  139. MD5 md5 = new MD5CryptoServiceProvider();
  140. PlayerPrefs.SetString("id", ManaServer.ID);
  141. PlayerPrefs.SetString("config", Auxiliary.ToString(md5.ComputeHash(bytes)));
  142. XmlDocument doc = new XmlDocument();
  143. doc.LoadXml(PlayerDoc.OuterXml);
  144. Auxiliary.EncryptXml(doc);
  145. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  146. sw.Write(doc.OuterXml);
  147. sw.Close();
  148. }
  149. }
  150. public static void RecoveXml(JsonData jsonData)
  151. {
  152. if (!DamageLock)
  153. {
  154. return;
  155. }
  156. DamageLock = false;
  157. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  158. DefaultDoc.LoadXml(textAsset.text);
  159. if (jsonData.Inst_Object.Keys.Contains("l"))
  160. {
  161. PlayerDoc_ = new XmlDocument();
  162. PlayerDoc_.LoadXml(jsonData["l"].ToString());
  163. int nativeVersion = int.Parse(PlayerDoc_.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  164. int defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  165. if (nativeVersion < defaultVersion)
  166. {
  167. MergeXML(nativeVersion, PlayerDoc_, DefaultDoc);
  168. }
  169. }
  170. else
  171. {
  172. PlayerDoc_ = DefaultDoc;
  173. }
  174. }
  175. public static void SaveSkillList()
  176. {
  177. if (ManaTutorial.TutorialA || !ManaCenter.Complete)
  178. {
  179. return;
  180. }
  181. XmlNode xmlNode;
  182. XmlAttribute xmlAttribute;
  183. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  184. xmlNode.RemoveAll();
  185. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  186. {
  187. if (ManaCenter.SkillList[i].SkillType == SkillType.Skill)
  188. {
  189. #region Skill
  190. Skill skill = (Skill)ManaCenter.SkillList[i];
  191. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  192. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  193. xmlAttribute.Value = skill.ID;
  194. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  195. xmlAttribute.Value = skill.SkillType.ToString();
  196. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  197. xmlAttribute.Value = skill.ItemStatus.ToString();
  198. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  199. xmlAttribute.Value = skill.Level.ToString();
  200. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
  201. xmlAttribute.Value = skill.CoolTimer.ToString("0");
  202. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
  203. xmlAttribute.Value = skill.UseTimer.ToString("0");
  204. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  205. #endregion
  206. }
  207. else if (ManaCenter.SkillList[i].SkillType == SkillType.Pack)
  208. {
  209. #region Pack
  210. Pack pack = (Pack)ManaCenter.SkillList[i];
  211. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  212. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  213. xmlAttribute.Value = pack.ID;
  214. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  215. xmlAttribute.Value = pack.SkillType.ToString();
  216. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  217. xmlAttribute.Value = pack.ItemStatus.ToString();
  218. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  219. xmlAttribute.Value = pack.Level.ToString();
  220. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  221. #endregion
  222. }
  223. else if (ManaCenter.SkillList[i].SkillType == SkillType.Ability)
  224. {
  225. #region Ability
  226. Ability ability = (Ability)ManaCenter.SkillList[i];
  227. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  228. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  229. xmlAttribute.Value = ability.ID;
  230. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  231. xmlAttribute.Value = ability.SkillType.ToString();
  232. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  233. xmlAttribute.Value = ability.ItemStatus.ToString();
  234. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  235. xmlAttribute.Value = ability.Level.ToString();
  236. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  237. #endregion
  238. }
  239. else if (ManaCenter.SkillList[i].SkillType == SkillType.BigSkill)
  240. {
  241. #region BigSkill
  242. BigSkill bigSkill = (BigSkill)ManaCenter.SkillList[i];
  243. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  244. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  245. xmlAttribute.Value = bigSkill.ID;
  246. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  247. xmlAttribute.Value = bigSkill.SkillType.ToString();
  248. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  249. xmlAttribute.Value = bigSkill.ItemStatus.ToString();
  250. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  251. xmlAttribute.Value = bigSkill.BarStatus.ToString();
  252. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  253. xmlAttribute.Value = bigSkill.Level.ToString();
  254. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
  255. xmlAttribute.Value = bigSkill.CoolTimer.ToString("0");
  256. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
  257. xmlAttribute.Value = bigSkill.UseTimer.ToString("0");
  258. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  259. #endregion
  260. }
  261. }
  262. }
  263. public static void SaveDress()
  264. {
  265. XmlNode xmlNode = PlayerNode.SelectSingleNode("DressList");
  266. xmlNode.Attributes[0].Value = "";
  267. for (int i = 0; i < ManaPlayer.BoughtCloseList.Count; i++)
  268. {
  269. xmlNode.Attributes[0].Value += ManaPlayer.BoughtCloseList[i] + " ";
  270. }
  271. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  272. xmlNode = PlayerNode.SelectSingleNode("DressData");
  273. for (int i = 0; i < ManaPlayer.DressData.Count; i++)
  274. {
  275. xmlNode.Attributes[i].Value = ManaPlayer.DressData[i];
  276. }
  277. }
  278. public static void SaveAchieve()
  279. {
  280. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  281. xmlNode.Attributes[0].Value = "";
  282. foreach (var kv in ManaAchieve.AchieveDic)
  283. {
  284. if (!kv.Value.Lock)
  285. {
  286. xmlNode.Attributes[0].Value += kv.Value.ID_ + " ";
  287. }
  288. }
  289. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  290. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = ManaCenter.AdAmt.ToString("0");
  291. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = ManaCenter.SkillAmt.ToString("0");
  292. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = ManaCenter.SignAmt.ToString("0");
  293. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = ManaCenter.ShareAmt.ToString("0");
  294. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = ManaCenter.ElfLevel.ToString("0");
  295. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = ManaCenter.MiniGameAmt.ToString("0");
  296. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = ManaCenter.FlowerCoin.ToString("0");
  297. PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value = ManaCenter.TotalPerson.ToString("0");
  298. }
  299. public static void SavePlantList()
  300. {
  301. if (ManaVisit.InVisit || ManaTutorial.TutorialA)
  302. {
  303. return;
  304. }
  305. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
  306. attribute[0].Value = "";
  307. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  308. {
  309. Slot slot = ManaGarden.PlantList[i];
  310. attribute[0].Value += slot.ID + "," + slot.Index + " ";
  311. }
  312. attribute[0].Value = attribute[0].Value.TrimEnd(' ');
  313. }
  314. public static void SaveCommon()
  315. {
  316. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaCenter.Coin.ToString("0");
  317. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaCenter.Diamond.ToString("0");
  318. PlayerNode.SelectSingleNode("SignTime").Attributes[0].Value = ManaSign.SignTime.ToString();
  319. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
  320. PlayerNode.SelectSingleNode("SignRound").Attributes[0].Value = ManaSign.SignRound.ToString();
  321. PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = ManaServer.Connect.ToInt().ToString();
  322. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = ManaServer.Time.ToString();
  323. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaCenter.MiniTimer.ToString("0");
  324. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaCenter.CircleTimer.ToString("0");
  325. PlayerNode.SelectSingleNode("ID").Attributes[0].Value = ManaServer.ID;
  326. PlayerNode.SelectSingleNode("Language").Attributes[0].Value = ManaLan.CurrentLan.ToString();
  327. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
  328. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = ManaTutorial.TutorialA.ToInt().ToString();
  329. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = ManaTutorial.TutorialB_.ToInt().ToString();
  330. PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = ManaTutorial.TutorialC_.ToInt().ToString();
  331. PlayerNode.SelectSingleNode("TutorialD").Attributes[0].Value = ManaTutorial.TutorialD_.ToInt().ToString();
  332. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = ManaTutorial.TutorialIndexA.ToString();
  333. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = ManaTutorial.TutorialIndexB.ToString();
  334. PlayerNode.SelectSingleNode("TutorialIndexC").Attributes[0].Value = ManaTutorial.TutorialIndexC.ToString();
  335. PlayerNode.SelectSingleNode("TutorialIndexD").Attributes[0].Value = ManaTutorial.TutorialIndexD.ToString();
  336. }
  337. public static void SaveFlowerList()
  338. {
  339. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  340. attribute.Value = "";
  341. foreach (var kv in ManaGarden.FlowerInfoDic)
  342. {
  343. if (kv.Value.Unlock)
  344. {
  345. attribute.Value += kv.Value.ID_ + " ";
  346. }
  347. }
  348. attribute.Value = attribute.Value.Trim(' ');
  349. }
  350. public static void SavePlayerConfig()
  351. {
  352. if (Initializer.Complete)
  353. {
  354. SaveSkillList();
  355. SaveAchieve();
  356. SaveDress();
  357. SavePlantList();
  358. SaveCommon();
  359. SaveFlowerList();
  360. }
  361. }
  362. public static void ResetPlayerConfig()
  363. {
  364. PlayerPrefs.SetString("id", "");
  365. PlayerNode.SelectSingleNode("Version").Attributes[0].Value = "10000";
  366. SavePlayerConfig();
  367. ManaCenter.SaveLock = true;
  368. }
  369. public static int GetPlayerInt(string node)
  370. {
  371. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  372. }
  373. public static bool GetPlayerBool(string node)
  374. {
  375. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
  376. }
  377. public static float GetPlayerFloat(string node)
  378. {
  379. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  380. }
  381. public static string GetPlayerString(string node)
  382. {
  383. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  384. }
  385. public static double GetPlayerDouble(string node)
  386. {
  387. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  388. }
  389. public static void SavePlayerInt(string node, int value)
  390. {
  391. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  392. }
  393. public static void SavePlayerBool(string node, bool value)
  394. {
  395. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
  396. }
  397. public static void SavePlayerFloat(string node, float value)
  398. {
  399. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  400. }
  401. public static void SavePlayerString(string node, string value)
  402. {
  403. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  404. }
  405. public static void SavePlayerDouble(string node, double value)
  406. {
  407. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  408. }
  409. public static List<int> GetDressList()
  410. {
  411. List<int> list = new List<int>();
  412. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("DressList").Attributes;
  413. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  414. }
  415. public static List<string> GetDressData(XmlNode node = null)
  416. {
  417. XmlNode xmlNode;
  418. if (node == null)
  419. {
  420. xmlNode = PlayerNode.SelectSingleNode("DressData");
  421. }
  422. else
  423. {
  424. xmlNode = node.SelectSingleNode("DressData");
  425. }
  426. List<string> dataList = new List<string>();
  427. dataList.Add(xmlNode.Attributes[0].Value);
  428. dataList.Add(xmlNode.Attributes[1].Value);
  429. dataList.Add(xmlNode.Attributes[2].Value);
  430. dataList.Add(xmlNode.Attributes[3].Value);
  431. dataList.Add(xmlNode.Attributes[4].Value);
  432. dataList.Add(xmlNode.Attributes[5].Value);
  433. dataList.Add(xmlNode.Attributes[6].Value);
  434. return dataList;
  435. }
  436. public static List<int> GetFlowerList()
  437. {
  438. List<int> list = new List<int>();
  439. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  440. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  441. }
  442. public static List<int> GetAchieveList()
  443. {
  444. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  445. }
  446. public static List<string> GetOfflineConfig()
  447. {
  448. TextAsset textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
  449. XmlDocument xmlDoc = new XmlDocument();
  450. xmlDoc.LoadXml(textAsset.text);
  451. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  452. List<string> strList = new List<string>()
  453. {
  454. xmlNode.Attributes[1].Value,
  455. xmlNode.Attributes[2].Value,
  456. xmlNode.Attributes[3].Value,
  457. };
  458. return strList;
  459. }
  460. public static List<double> GetAchieveData()
  461. {
  462. List<double> dataList = new List<double>();
  463. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  464. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  465. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  466. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  467. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  468. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  469. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  470. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
  471. return dataList;
  472. }
  473. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  474. {
  475. List<KV<int, int>> list = new List<KV<int, int>>();
  476. XmlNode xmlNode;
  477. if (node == null)
  478. {
  479. xmlNode = PlayerNode.SelectSingleNode("PlantList");
  480. }
  481. else
  482. {
  483. xmlNode = node.SelectSingleNode("PlantList");
  484. }
  485. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  486. {
  487. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  488. for (int i = 0; i < strings.Length; i++)
  489. {
  490. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  491. }
  492. }
  493. return list;
  494. }
  495. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  496. {
  497. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  498. XmlNodeList xmlNodeList;
  499. if (node == null)
  500. {
  501. xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  502. }
  503. else
  504. {
  505. xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
  506. }
  507. for (int i = 0; i < xmlNodeList.Count; i++)
  508. {
  509. attributeList.Add(xmlNodeList[i].Attributes);
  510. }
  511. return attributeList;
  512. }
  513. public static XmlAttributeCollection GetVisitConfig()
  514. {
  515. TextAsset textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
  516. XmlDocument xmlDoc = new XmlDocument();
  517. xmlDoc.LoadXml(textAsset.text);
  518. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  519. return xmlNode.Attributes;
  520. }
  521. public static XmlAttributeCollection GetAwardConfig()
  522. {
  523. TextAsset textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
  524. XmlDocument xmlDoc = new XmlDocument();
  525. xmlDoc.LoadXml(textAsset.text);
  526. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  527. return xmlNode.Attributes;
  528. }
  529. public static List<XmlAttributeCollection> GetSkillConfig()
  530. {
  531. TextAsset textAsset;
  532. XmlDocument xmlDoc = new XmlDocument();
  533. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  534. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  535. textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
  536. xmlDoc.LoadXml(textAsset.text);
  537. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  538. textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
  539. xmlDoc.LoadXml(textAsset.text);
  540. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  541. textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
  542. xmlDoc.LoadXml(textAsset.text);
  543. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  544. for (int i = 0; i < xmlNodeList.Count; i++)
  545. {
  546. for (int j = 0; j < xmlNodeList[i].Count; j++)
  547. {
  548. attributeList.Add(xmlNodeList[i][j].Attributes);
  549. }
  550. }
  551. return attributeList;
  552. }
  553. public static List<XmlAttributeCollection> GetSignConfig()
  554. {
  555. TextAsset textAsset;
  556. XmlNodeList xmlNodeList;
  557. XmlDocument xmlDoc = new XmlDocument();
  558. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  559. textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
  560. xmlDoc.LoadXml(textAsset.text);
  561. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  562. for (int i = 0; i < xmlNodeList.Count; i++)
  563. {
  564. attributeList.Add(xmlNodeList[i].Attributes);
  565. }
  566. return attributeList;
  567. }
  568. public static List<XmlAttributeCollection> GetFlowerConfig()
  569. {
  570. TextAsset textAsset;
  571. XmlNodeList xmlNodeList;
  572. XmlDocument xmlDoc = new XmlDocument();
  573. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  574. textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
  575. xmlDoc.LoadXml(textAsset.text);
  576. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  577. for (int i = 0; i < xmlNodeList.Count; i++)
  578. {
  579. attributeList.Add(xmlNodeList[i].Attributes);
  580. }
  581. return attributeList;
  582. }
  583. public static List<XmlAttributeCollection> GetAchieveConfig()
  584. {
  585. TextAsset textAsset;
  586. XmlNodeList xmlNodeList;
  587. XmlDocument xmlDoc = new XmlDocument();
  588. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  589. textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
  590. xmlDoc.LoadXml(textAsset.text);
  591. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  592. for (int i = 0; i < xmlNodeList.Count; i++)
  593. {
  594. attributeList.Add(xmlNodeList[i].Attributes);
  595. }
  596. return attributeList;
  597. }
  598. public static List<XmlAttributeCollection> GetDressRoomConfig()
  599. {
  600. TextAsset textAsset;
  601. XmlNodeList xmlNodeList;
  602. XmlDocument xmlDoc = new XmlDocument();
  603. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  604. textAsset = ManaReso.Load<TextAsset>("dressRoom_config", Folder.Config);
  605. xmlDoc.LoadXml(textAsset.text);
  606. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  607. for (int i = 0; i < xmlNodeList.Count; i++)
  608. {
  609. attributeList.Add(xmlNodeList[i].Attributes);
  610. }
  611. return attributeList;
  612. }
  613. public static XmlDocument MergeXML(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  614. {
  615. if (nativeVersion < 670)
  616. {
  617. To670(nativeDoc, defaultDoc);
  618. }
  619. return nativeDoc;
  620. }
  621. public static XmlDocument To670(XmlDocument nativeDoc, XmlDocument defaultDoc)
  622. {
  623. string playerType = "";
  624. XmlNode xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressList");
  625. XmlNode xmlNode2 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
  626. XmlNode xmlNode3 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialD");
  627. XmlNode xmlNode4 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexD");
  628. XmlNode xmlNode5 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Player");
  629. if (xmlNode1 != null)
  630. {
  631. nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode1);
  632. }
  633. if (xmlNode2 != null)
  634. {
  635. nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode2);
  636. }
  637. if (xmlNode3 != null)
  638. {
  639. nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode3);
  640. }
  641. if (xmlNode4 != null)
  642. {
  643. nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode4);
  644. }
  645. if (xmlNode5 != null)
  646. {
  647. playerType = xmlNode5.Attributes[0].Value;
  648. nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode5);
  649. }
  650. else
  651. {
  652. playerType = "PlayerBlond";
  653. }
  654. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 670.ToString();
  655. xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressList");
  656. xmlNode2 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
  657. xmlNode3 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialD");
  658. xmlNode4 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexD");
  659. xmlNode5 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Player");
  660. if (playerType == "PlayerBlond")
  661. {
  662. xmlNode2.Attributes[0].Value = "脑壳1";
  663. xmlNode2.Attributes[1].Value = "裙子1";
  664. xmlNode2.Attributes[2].Value = "鞋子1";
  665. xmlNode2.Attributes[3].Value = "头饰品1";
  666. xmlNode2.Attributes[4].Value = "上衣1";
  667. xmlNode2.Attributes[5].Value = "眼睛1";
  668. xmlNode2.Attributes[6].Value = "嘴巴1";
  669. }
  670. else if (playerType == "PlayerBrown")
  671. {
  672. xmlNode2.Attributes[0].Value = "脑壳2";
  673. xmlNode2.Attributes[1].Value = "裙子2";
  674. xmlNode2.Attributes[2].Value = "鞋子2";
  675. xmlNode2.Attributes[3].Value = "头饰品2";
  676. xmlNode2.Attributes[4].Value = "上衣2";
  677. xmlNode2.Attributes[5].Value = "眼睛2";
  678. xmlNode2.Attributes[6].Value = "嘴巴2";
  679. }
  680. else if (playerType == "PlayerPink")
  681. {
  682. xmlNode2.Attributes[0].Value = "脑壳3";
  683. xmlNode2.Attributes[1].Value = "裙子3";
  684. xmlNode2.Attributes[2].Value = "鞋子3";
  685. xmlNode2.Attributes[3].Value = "头饰品3";
  686. xmlNode2.Attributes[4].Value = "上衣3";
  687. xmlNode2.Attributes[5].Value = "眼睛3";
  688. xmlNode2.Attributes[6].Value = "嘴巴3";
  689. }
  690. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  691. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode2, true));
  692. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode3, true));
  693. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode4, true));
  694. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode5, true));
  695. return nativeDoc;
  696. }
  697. }