ManaData.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  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.Linq;
  10. using System.Security.Cryptography;
  11. using Sfs2X.Entities;
  12. using Sfs2X.Entities.Data;
  13. using Random = UnityEngine.Random;
  14. public class ManaData : Regist
  15. {
  16. #region 变量
  17. public static XmlNode PlayerNode
  18. {
  19. get
  20. {
  21. if (PlayerNode_ == null)
  22. {
  23. PlayerNode_ = PlayerDoc.SelectSingleNode("PlayerConfig");
  24. }
  25. return PlayerNode_;
  26. }
  27. set { PlayerNode_ = value; }
  28. }
  29. public static XmlDocument PlayerDoc
  30. {
  31. get
  32. {
  33. if (PlayerDoc_ == null)
  34. {
  35. int defaultVersion;
  36. int nativeVersion;
  37. XmlNode node;
  38. XmlDocument nativeDoc = new XmlDocument();
  39. string configPath = Application.persistentDataPath + "/PlayerConfig.xml";
  40. if (File.Exists(configPath))
  41. {
  42. try
  43. {
  44. StreamReader sr = new StreamReader(configPath);
  45. nativeDoc.LoadXml(sr.ReadToEnd());
  46. sr.Close();
  47. Auxiliary.DecryptXml(nativeDoc);
  48. }
  49. catch (Exception)
  50. {
  51. Debug.LogWarning("Download Archive : MD5 doesn't match");
  52. ManaDebug.Log("Download Archive");
  53. DamageLock = true;
  54. DownloadLock = false;
  55. return null;
  56. }
  57. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  58. DefaultDoc.LoadXml(textAsset.text);
  59. defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  60. node = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version");
  61. if (node == null)
  62. {
  63. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  64. sw.Write(DefaultDoc.OuterXml);
  65. sw.Close();
  66. PlayerDoc_ = DefaultDoc;
  67. }
  68. else
  69. {
  70. nativeVersion = int.Parse(node.Attributes[0].Value);
  71. if (nativeVersion < defaultVersion)
  72. {
  73. byte[] bytes;
  74. MD5 md5 = new MD5CryptoServiceProvider();
  75. if (nativeVersion <= 4)
  76. {
  77. bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
  78. }
  79. else
  80. {
  81. bytes = File.ReadAllBytes(configPath);
  82. }
  83. if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
  84. {
  85. Debug.LogWarning("Download Archive : MD5 doesn't match");
  86. ManaDebug.Log("Download Archive");
  87. DamageLock = true;
  88. DownloadLock = false;
  89. return null;
  90. }
  91. else
  92. {
  93. PlayerDoc_ = MergeXML(nativeVersion, nativeDoc, DefaultDoc);
  94. ManaServer.Save();
  95. }
  96. }
  97. else if (nativeVersion > defaultVersion)
  98. {
  99. PlayerDoc_ = DefaultDoc;
  100. }
  101. else
  102. {
  103. byte[] bytes = File.ReadAllBytes(configPath);
  104. MD5 md5 = new MD5CryptoServiceProvider();
  105. if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
  106. {
  107. Debug.LogWarning("Download Archive : MD5 doesn't match");
  108. ManaDebug.Log("Download Archive");
  109. DamageLock = true;
  110. DownloadLock = false;
  111. return null;
  112. }
  113. PlayerDoc_ = nativeDoc;
  114. }
  115. }
  116. }
  117. else
  118. {
  119. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  120. DefaultDoc.LoadXml(textAsset.text);
  121. Debug.LogWarning("Download Archive");
  122. ManaDebug.Log("Download Archive");
  123. DamageLock = true;
  124. DownloadLock = false;
  125. return null;
  126. }
  127. }
  128. return PlayerDoc_;
  129. }
  130. set { PlayerDoc_ = value; }
  131. }
  132. public static XmlNode PlayerNode_;
  133. public static XmlDocument PlayerDoc_;
  134. public static float Timer;
  135. public static bool DamageLock;
  136. public static bool DownloadLock;
  137. public static XmlDocument DefaultDoc = new XmlDocument();
  138. #endregion
  139. public void Update()
  140. {
  141. if (DamageLock)
  142. {
  143. Timer += Time.deltaTime;
  144. if (Timer >= 10)
  145. {
  146. DamageLock = false;
  147. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  148. PlayerDoc_ = new XmlDocument();
  149. PlayerDoc_.LoadXml(textAsset.text);
  150. return;
  151. }
  152. }
  153. if (!DownloadLock)
  154. {
  155. if (ManaServer.ID != "Default")
  156. {
  157. DownloadLock = true;
  158. ManaServer.DownloadBySerialNumber(ManaServer.SerialNumber, RecoveXml);
  159. }
  160. }
  161. }
  162. public override bool RegistImmed()
  163. {
  164. if (base.RegistImmed())
  165. {
  166. return true;
  167. }
  168. enabled = true;
  169. return false;
  170. }
  171. public static void SaveXml()
  172. {
  173. if (Initializer.Complete)
  174. {
  175. XmlDocument doc = new XmlDocument();
  176. doc.LoadXml(PlayerDoc.OuterXml);
  177. Auxiliary.EncryptXml(doc);
  178. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  179. sw.Write(doc.OuterXml);
  180. sw.Close();
  181. byte[] bytes = File.ReadAllBytes(Application.persistentDataPath + "/PlayerConfig.xml");
  182. //byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
  183. MD5 md5 = new MD5CryptoServiceProvider();
  184. PlayerPrefs.SetString("config", Auxiliary.ToString(md5.ComputeHash(bytes)));
  185. }
  186. }
  187. public static void RecoveXml(JsonData jsonData)
  188. {
  189. if (!DamageLock)
  190. {
  191. return;
  192. }
  193. DamageLock = false;
  194. TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
  195. DefaultDoc.LoadXml(textAsset.text);
  196. if (jsonData.Inst_Object.Keys.Contains("l"))
  197. {
  198. PlayerDoc_ = new XmlDocument();
  199. PlayerDoc_.LoadXml(jsonData["l"].ToString());
  200. int nativeVersion = int.Parse(PlayerDoc_.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  201. int defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  202. //Debug.Log(nativeVersion + " " + defaultVersion);
  203. //ManaDebug.Log(nativeVersion + " " + defaultVersion);
  204. if (nativeVersion < defaultVersion)
  205. {
  206. MergeXML(nativeVersion, PlayerDoc_, DefaultDoc);
  207. ManaServer.Save();
  208. }
  209. else if (nativeVersion > defaultVersion)
  210. {
  211. PlayerDoc_ = DefaultDoc;
  212. }
  213. }
  214. else
  215. {
  216. PlayerDoc_ = DefaultDoc;
  217. }
  218. }
  219. public static void SaveSkillList()
  220. {
  221. if (ManaTutorial.TutorialA || !ManaCenter.Complete)
  222. {
  223. return;
  224. }
  225. XmlNode xmlNode;
  226. XmlAttribute xmlAttribute;
  227. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  228. xmlNode.RemoveAll();
  229. for (int i = 0; i < ManaCenter.SkillList.Count; i++)
  230. {
  231. if (ManaCenter.SkillList[i].SkillType == SkillType.Skill)
  232. {
  233. #region Skill
  234. Skill skill = (Skill)ManaCenter.SkillList[i];
  235. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  236. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  237. xmlAttribute.Value = skill.ID;
  238. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  239. xmlAttribute.Value = skill.SkillType.ToString();
  240. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  241. xmlAttribute.Value = skill.ItemStatus.ToString();
  242. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  243. xmlAttribute.Value = skill.Level.ToString();
  244. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
  245. xmlAttribute.Value = skill.CoolTimer.ToString("0");
  246. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
  247. xmlAttribute.Value = skill.UseTimer.ToString("0");
  248. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  249. #endregion
  250. }
  251. else if (ManaCenter.SkillList[i].SkillType == SkillType.Pack)
  252. {
  253. #region Pack
  254. Pack pack = (Pack)ManaCenter.SkillList[i];
  255. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  256. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  257. xmlAttribute.Value = pack.ID;
  258. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  259. xmlAttribute.Value = pack.SkillType.ToString();
  260. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  261. xmlAttribute.Value = pack.ItemStatus.ToString();
  262. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  263. xmlAttribute.Value = pack.Level.ToString();
  264. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  265. #endregion
  266. }
  267. else if (ManaCenter.SkillList[i].SkillType == SkillType.Ability)
  268. {
  269. #region Ability
  270. Ability ability = (Ability)ManaCenter.SkillList[i];
  271. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  272. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  273. xmlAttribute.Value = ability.ID;
  274. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  275. xmlAttribute.Value = ability.SkillType.ToString();
  276. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  277. xmlAttribute.Value = ability.ItemStatus.ToString();
  278. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  279. xmlAttribute.Value = ability.Level.ToString();
  280. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  281. #endregion
  282. }
  283. else if (ManaCenter.SkillList[i].SkillType == SkillType.BigSkill)
  284. {
  285. #region BigSkill
  286. BigSkill bigSkill = (BigSkill)ManaCenter.SkillList[i];
  287. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  288. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  289. xmlAttribute.Value = bigSkill.ID;
  290. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  291. xmlAttribute.Value = bigSkill.SkillType.ToString();
  292. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  293. xmlAttribute.Value = bigSkill.ItemStatus.ToString();
  294. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  295. xmlAttribute.Value = bigSkill.BarStatus.ToString();
  296. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  297. xmlAttribute.Value = bigSkill.Level.ToString();
  298. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
  299. xmlAttribute.Value = bigSkill.CoolTimer.ToString("0");
  300. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
  301. xmlAttribute.Value = bigSkill.UseTimer.ToString("0");
  302. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  303. #endregion
  304. }
  305. }
  306. }
  307. public static void SaveDress()
  308. {
  309. XmlNode xmlNode = PlayerNode.SelectSingleNode("DressList");
  310. xmlNode.Attributes[0].Value = "";
  311. for (int i = 0; i < ManaPlayer.BoughtCloseList.Count; i++)
  312. {
  313. xmlNode.Attributes[0].Value += ManaPlayer.BoughtCloseList[i] + " ";
  314. }
  315. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  316. xmlNode = PlayerNode.SelectSingleNode("DressData");
  317. for (int i = 0; i < ManaPlayer.DressData.Count; i++)
  318. {
  319. xmlNode.Attributes[i].Value = ManaPlayer.DressData[i];
  320. }
  321. }
  322. public static void SaveAchieve()
  323. {
  324. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  325. xmlNode.Attributes[0].Value = "";
  326. foreach (var kv in ManaAchieve.AchieveDic)
  327. {
  328. if (!kv.Value.Lock)
  329. {
  330. xmlNode.Attributes[0].Value += kv.Value.ID_ + " ";
  331. }
  332. }
  333. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  334. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = ManaCenter.AdAmt.ToString("0");
  335. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = ManaCenter.SkillAmt.ToString("0");
  336. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = ManaCenter.SignAmt.ToString("0");
  337. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = ManaCenter.ShareAmt.ToString("0");
  338. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = ManaCenter.ElfLevel.ToString("0");
  339. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = ManaCenter.MiniGameAmt.ToString("0");
  340. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = ManaCenter.FlowerCoin.ToString("0");
  341. PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value = ManaCenter.TotalPerson.ToString("0");
  342. PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value = ManaCenter.CostDiamond.ToString("0");
  343. }
  344. public static void SavePlantList()
  345. {
  346. if (ManaVisit.InVisit || ManaTutorial.TutorialA)
  347. {
  348. return;
  349. }
  350. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
  351. attribute[0].Value = "";
  352. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  353. {
  354. Slot slot = ManaGarden.PlantList[i];
  355. attribute[0].Value += slot.ID + "," + slot.Index + " ";
  356. }
  357. attribute[0].Value = attribute[0].Value.TrimEnd(' ');
  358. }
  359. public static void SaveCommon()
  360. {
  361. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaCenter.Coin.ToString("0");
  362. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaCenter.Diamond.ToString("0");
  363. PlayerNode.SelectSingleNode("SignTime").Attributes[0].Value = ManaSign.SignTime.ToString();
  364. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
  365. PlayerNode.SelectSingleNode("SignRound").Attributes[0].Value = ManaSign.SignRound.ToString();
  366. PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = ManaServer.Connect.ToInt().ToString();
  367. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = ManaServer.Time.ToString();
  368. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaCenter.MiniTimer.ToString("0");
  369. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaCenter.CircleTimer.ToString("0");
  370. PlayerNode.SelectSingleNode("ID").Attributes[0].Value = ManaServer.ID;
  371. PlayerNode.SelectSingleNode("SerialNumber").Attributes[0].Value = ManaServer.SerialNumber;
  372. PlayerNode.SelectSingleNode("Language").Attributes[0].Value = ManaLan.CurrentLan.ToString();
  373. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
  374. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = ManaTutorial.TutorialA.ToInt().ToString();
  375. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = ManaTutorial.TutorialB_.ToInt().ToString();
  376. PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = ManaTutorial.TutorialC_.ToInt().ToString();
  377. PlayerNode.SelectSingleNode("TutorialD").Attributes[0].Value = ManaTutorial.TutorialD_.ToInt().ToString();
  378. PlayerNode.SelectSingleNode("TutorialE").Attributes[0].Value = ManaTutorial.TutorialE_.ToInt().ToString();
  379. PlayerNode.SelectSingleNode("TutorialPlazaRoom").Attributes[0].Value = ManaTutorial.TutorialPlazaRoom_.ToInt().ToString();
  380. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = ManaTutorial.TutorialIndexA.ToString();
  381. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = ManaTutorial.TutorialIndexB.ToString();
  382. PlayerNode.SelectSingleNode("TutorialIndexC").Attributes[0].Value = ManaTutorial.TutorialIndexC.ToString();
  383. PlayerNode.SelectSingleNode("TutorialIndexD").Attributes[0].Value = ManaTutorial.TutorialIndexD.ToString();
  384. PlayerNode.SelectSingleNode("TutorialIndexE").Attributes[0].Value = ManaTutorial.TutorialIndexE.ToString();
  385. PlayerNode.SelectSingleNode("TutorialIndexPlazaRoom").Attributes[0].Value = ManaTutorial.TutorialIndexPlazaRoom.ToString();
  386. }
  387. public static void SaveFlowers()
  388. {
  389. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  390. XmlAttribute attribute1 = PlayerNode.SelectSingleNode("FlowerAmtList").Attributes[0];
  391. attribute.Value = "";
  392. attribute1.Value = "";
  393. foreach (var kv in ManaGarden.FlowerInfoDic)
  394. {
  395. if (kv.Value.Unlock)
  396. {
  397. attribute.Value += kv.Value.ID_ + " ";
  398. attribute1.Value += kv.Value.Amount + " ";
  399. }
  400. }
  401. attribute.Value = attribute.Value.Trim(' ');
  402. attribute1.Value = attribute1.Value.Trim(' ');
  403. }
  404. public static void SavePlayerConfig()
  405. {
  406. if (Initializer.Complete)
  407. {
  408. SaveSkillList();
  409. SaveAchieve();
  410. SaveDress();
  411. SavePlantList();
  412. SaveCommon();
  413. SaveFlowers();
  414. ChestMge.Save();
  415. }
  416. }
  417. public static void ResetPlayerConfig()
  418. {
  419. PlayerNode.SelectSingleNode("Version").Attributes[0].Value = "10000";
  420. SavePlayerConfig();
  421. ManaCenter.SaveLock = true;
  422. }
  423. public static int GetPlayerInt(string node)
  424. {
  425. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  426. }
  427. public static bool GetPlayerBool(string node)
  428. {
  429. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
  430. }
  431. public static float GetPlayerFloat(string node)
  432. {
  433. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  434. }
  435. public static string GetPlayerString(string node)
  436. {
  437. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  438. }
  439. public static double GetPlayerDouble(string node)
  440. {
  441. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  442. }
  443. public static void SavePlayerInt(string node, int value)
  444. {
  445. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  446. }
  447. public static void SavePlayerBool(string node, bool value)
  448. {
  449. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
  450. }
  451. public static void SavePlayerFloat(string node, float value)
  452. {
  453. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  454. }
  455. public static void SavePlayerString(string node, string value)
  456. {
  457. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  458. }
  459. public static void SavePlayerDouble(string node, double value)
  460. {
  461. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  462. }
  463. public static List<int> GetIntList(char splitChar, string nodeName, List<int> defaultList)
  464. {
  465. return Auxiliary.IntListParse(splitChar, PlayerNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  466. }
  467. public static List<string> GetStringList(char splitChar, string nodeName, List<string> defaultList)
  468. {
  469. return Auxiliary.StringListParse(splitChar, PlayerNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  470. }
  471. public static List<int> GetDressList()
  472. {
  473. List<int> list = new List<int>();
  474. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("DressList").Attributes;
  475. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  476. }
  477. public static List<int> GetDressDataIDs(Player player)
  478. {
  479. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  480. //{
  481. // Debug.LogWarning(VARIABLE.Key);
  482. //}
  483. List<int> dressDataIDs = new List<int>();
  484. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Head]);
  485. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Dress]);
  486. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Shoe]);
  487. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.HeadWear]);
  488. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Top]);
  489. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Eye]);
  490. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Mouse]);
  491. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Wing]);
  492. return dressDataIDs;
  493. }
  494. public static List<int> GetDressDataIDs(ISFSObject parameter)
  495. {
  496. List<int> ids = parameter.GetIntArray(InfoLabel.Close.GetHashString()).ToList();
  497. return ids;
  498. }
  499. public static List<string> GetDressData(SFSObject parameter)
  500. {
  501. List<int> ids = GetDressDataIDs(parameter);
  502. List<string> dressData = new List<string>();
  503. foreach (var id in ids)
  504. {
  505. dressData.Add(ManaPlayer.CloseUnitDic[id].ArmatureName);
  506. }
  507. return dressData;
  508. }
  509. public static List<string> GetDressData(XmlNode node = null)
  510. {
  511. XmlNode xmlNode;
  512. if (node == null)
  513. {
  514. xmlNode = PlayerNode.SelectSingleNode("DressData");
  515. }
  516. else
  517. {
  518. xmlNode = node.SelectSingleNode("DressData");
  519. }
  520. List<string> dataList = new List<string>();
  521. if (xmlNode != null && xmlNode.Attributes.Count == 12)
  522. {
  523. dataList.Add(xmlNode.Attributes[0].Value);
  524. dataList.Add(xmlNode.Attributes[1].Value);
  525. dataList.Add(xmlNode.Attributes[2].Value);
  526. dataList.Add(xmlNode.Attributes[3].Value);
  527. dataList.Add(xmlNode.Attributes[4].Value);
  528. dataList.Add(xmlNode.Attributes[5].Value);
  529. dataList.Add(xmlNode.Attributes[6].Value);
  530. dataList.Add(xmlNode.Attributes[7].Value);
  531. dataList.Add(xmlNode.Attributes[8].Value);
  532. dataList.Add(xmlNode.Attributes[9].Value);
  533. dataList.Add(xmlNode.Attributes[10].Value);
  534. dataList.Add(xmlNode.Attributes[11].Value);
  535. //dataList[8] = "长袖9左";
  536. //dataList[9] = "Empty";
  537. //dataList[10] = "长袖9右";
  538. //dataList[11] = "Empty";
  539. }
  540. else if(xmlNode != null && xmlNode.Attributes.Count == 8)
  541. {
  542. dataList.Add(xmlNode.Attributes[0].Value);
  543. dataList.Add(xmlNode.Attributes[1].Value);
  544. dataList.Add(xmlNode.Attributes[2].Value);
  545. dataList.Add(xmlNode.Attributes[3].Value);
  546. dataList.Add(xmlNode.Attributes[4].Value);
  547. dataList.Add(xmlNode.Attributes[5].Value);
  548. dataList.Add(xmlNode.Attributes[6].Value);
  549. dataList.Add(xmlNode.Attributes[7].Value);
  550. dataList.AddRange (GetSleeveListByTop(xmlNode.Attributes[4].Value));
  551. }
  552. else
  553. {
  554. float rate = Random.Range(0f, 1f);
  555. if (rate < 0.33f)
  556. {
  557. dataList.Add("脑壳1");
  558. dataList.Add("裙子1");
  559. dataList.Add("鞋子1");
  560. dataList.Add("头饰品1");
  561. dataList.Add("上衣1");
  562. dataList.Add("眼睛1");
  563. dataList.Add("嘴巴1");
  564. dataList.Add("Empty");
  565. dataList.Add("Empty");
  566. dataList.Add("短袖1左");
  567. dataList.Add("Empty");
  568. dataList.Add("短袖1右");
  569. }
  570. else if (rate < 0.66f)
  571. {
  572. dataList.Add("脑壳2");
  573. dataList.Add("裙子2");
  574. dataList.Add("鞋子2");
  575. dataList.Add("头饰品2");
  576. dataList.Add("上衣2");
  577. dataList.Add("眼睛2");
  578. dataList.Add("嘴巴2");
  579. dataList.Add("Empty");
  580. dataList.Add("Empty");
  581. dataList.Add("短袖2左");
  582. dataList.Add("Empty");
  583. dataList.Add("短袖2右");
  584. }
  585. else
  586. {
  587. dataList.Add("脑壳3");
  588. dataList.Add("裙子3");
  589. dataList.Add("鞋子3");
  590. dataList.Add("头饰品3");
  591. dataList.Add("上衣3");
  592. dataList.Add("眼睛3");
  593. dataList.Add("嘴巴3");
  594. dataList.Add("Empty");
  595. dataList.Add("Empty");
  596. dataList.Add("短袖2左");
  597. dataList.Add("Empty");
  598. dataList.Add("短袖2右");
  599. }
  600. }
  601. return dataList;
  602. }
  603. public static List<int> GetFlowerList()
  604. {
  605. List<int> list = new List<int>();
  606. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  607. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  608. }
  609. public static List<int> GetAchieveList()
  610. {
  611. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  612. }
  613. public static List<string> GetOfflineConfig()
  614. {
  615. TextAsset textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
  616. XmlDocument xmlDoc = new XmlDocument();
  617. xmlDoc.LoadXml(textAsset.text);
  618. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  619. List<string> strList = new List<string>()
  620. {
  621. xmlNode.Attributes[1].Value,
  622. xmlNode.Attributes[2].Value,
  623. xmlNode.Attributes[3].Value,
  624. };
  625. return strList;
  626. }
  627. public static List<double> GetAchieveData()
  628. {
  629. List<double> dataList = new List<double>();
  630. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  631. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  632. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  633. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  634. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  635. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  636. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  637. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
  638. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value));
  639. return dataList;
  640. }
  641. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  642. {
  643. List<KV<int, int>> list = new List<KV<int, int>>();
  644. XmlNode xmlNode;
  645. if (node == null)
  646. {
  647. xmlNode = PlayerNode.SelectSingleNode("PlantList");
  648. }
  649. else
  650. {
  651. xmlNode = node.SelectSingleNode("PlantList");
  652. }
  653. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  654. {
  655. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  656. for (int i = 0; i < strings.Length; i++)
  657. {
  658. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  659. }
  660. }
  661. return list;
  662. }
  663. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  664. {
  665. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  666. XmlNodeList xmlNodeList;
  667. if (node == null)
  668. {
  669. xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  670. }
  671. else
  672. {
  673. xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
  674. }
  675. for (int i = 0; i < xmlNodeList.Count; i++)
  676. {
  677. attributeList.Add(xmlNodeList[i].Attributes);
  678. }
  679. return attributeList;
  680. }
  681. public static XmlAttributeCollection GetVisitConfig()
  682. {
  683. TextAsset textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
  684. XmlDocument xmlDoc = new XmlDocument();
  685. xmlDoc.LoadXml(textAsset.text);
  686. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  687. return xmlNode.Attributes;
  688. }
  689. public static XmlAttributeCollection GetPlazaRoomConfig()
  690. {
  691. TextAsset textAsset = ManaReso.Load<TextAsset>("plaza_room_config", Folder.Config);
  692. XmlDocument xmlDoc = new XmlDocument();
  693. xmlDoc.LoadXml(textAsset.text);
  694. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  695. return xmlNode.Attributes;
  696. }
  697. public static XmlAttributeCollection GetAwardConfig()
  698. {
  699. TextAsset textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
  700. XmlDocument xmlDoc = new XmlDocument();
  701. xmlDoc.LoadXml(textAsset.text);
  702. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  703. return xmlNode.Attributes;
  704. }
  705. public static List<XmlAttributeCollection> GetIAPConfig()
  706. {
  707. TextAsset textAsset;
  708. XmlNodeList xmlNodeList;
  709. XmlDocument xmlDoc = new XmlDocument();
  710. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  711. textAsset = ManaReso.Load<TextAsset>("iap_config", Folder.Config);
  712. xmlDoc.LoadXml(textAsset.text);
  713. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  714. for (int i = 0; i < xmlNodeList.Count; i++)
  715. {
  716. attributeList.Add(xmlNodeList[i].Attributes);
  717. }
  718. return attributeList;
  719. }
  720. public static List<XmlAttributeCollection> GetSkillConfig()
  721. {
  722. TextAsset textAsset;
  723. XmlDocument xmlDoc = new XmlDocument();
  724. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  725. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  726. textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
  727. xmlDoc.LoadXml(textAsset.text);
  728. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  729. textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
  730. xmlDoc.LoadXml(textAsset.text);
  731. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  732. textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
  733. xmlDoc.LoadXml(textAsset.text);
  734. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  735. for (int i = 0; i < xmlNodeList.Count; i++)
  736. {
  737. for (int j = 0; j < xmlNodeList[i].Count; j++)
  738. {
  739. attributeList.Add(xmlNodeList[i][j].Attributes);
  740. }
  741. }
  742. return attributeList;
  743. }
  744. public static List<XmlAttributeCollection> GetSignConfig()
  745. {
  746. TextAsset textAsset;
  747. XmlNodeList xmlNodeList;
  748. XmlDocument xmlDoc = new XmlDocument();
  749. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  750. textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
  751. xmlDoc.LoadXml(textAsset.text);
  752. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  753. for (int i = 0; i < xmlNodeList.Count; i++)
  754. {
  755. attributeList.Add(xmlNodeList[i].Attributes);
  756. }
  757. return attributeList;
  758. }
  759. public static List<XmlAttributeCollection> GetFlowerConfig()
  760. {
  761. TextAsset textAsset;
  762. XmlNodeList xmlNodeList;
  763. XmlDocument xmlDoc = new XmlDocument();
  764. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  765. textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
  766. xmlDoc.LoadXml(textAsset.text);
  767. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  768. for (int i = 0; i < xmlNodeList.Count; i++)
  769. {
  770. attributeList.Add(xmlNodeList[i].Attributes);
  771. }
  772. return attributeList;
  773. }
  774. public static List<XmlAttributeCollection> GetLotteryConfig()
  775. {
  776. TextAsset textAsset;
  777. XmlNodeList xmlNodeList;
  778. XmlDocument xmlDoc = new XmlDocument();
  779. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  780. textAsset = ManaReso.Load<TextAsset>("lottery_config", Folder.Config);
  781. xmlDoc.LoadXml(textAsset.text);
  782. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  783. for (int i = 0; i < xmlNodeList.Count; i++)
  784. {
  785. attributeList.Add(xmlNodeList[i].Attributes);
  786. }
  787. return attributeList;
  788. }
  789. public static List<XmlAttributeCollection> GetAchieveConfig()
  790. {
  791. TextAsset textAsset;
  792. XmlNodeList xmlNodeList;
  793. XmlDocument xmlDoc = new XmlDocument();
  794. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  795. textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
  796. xmlDoc.LoadXml(textAsset.text);
  797. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  798. for (int i = 0; i < xmlNodeList.Count; i++)
  799. {
  800. attributeList.Add(xmlNodeList[i].Attributes);
  801. }
  802. return attributeList;
  803. }
  804. public static List<XmlAttributeCollection> GetDressRoomConfig()
  805. {
  806. TextAsset textAsset;
  807. XmlNodeList xmlNodeList;
  808. XmlDocument xmlDoc = new XmlDocument();
  809. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  810. textAsset = ManaReso.Load<TextAsset>("dressRoom_config", Folder.Config);
  811. xmlDoc.LoadXml(textAsset.text);
  812. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  813. for (int i = 0; i < xmlNodeList.Count; i++)
  814. {
  815. attributeList.Add(xmlNodeList[i].Attributes);
  816. }
  817. return attributeList;
  818. }
  819. public static XmlDocument MergeXML(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  820. {
  821. if (nativeVersion < 0)
  822. {
  823. Debug.LogWarning("UpdateArchive to 0");
  824. To0(nativeDoc, defaultDoc);
  825. }
  826. if (nativeVersion < 1)
  827. {
  828. Debug.LogWarning("UpdateArchive to 1");
  829. To1(nativeDoc, defaultDoc);
  830. }
  831. if (nativeVersion < 2)
  832. {
  833. Debug.LogWarning("UpdateArchive to 2");
  834. To2(nativeDoc, defaultDoc);
  835. }
  836. if (nativeVersion < 3)
  837. {
  838. Debug.LogWarning("UpdateArchive to 3");
  839. To3(nativeDoc, defaultDoc);
  840. }
  841. if (nativeVersion < 4)
  842. {
  843. Debug.LogWarning("UpdateArchive to 4");
  844. To4(nativeDoc, defaultDoc);
  845. }
  846. if (nativeVersion < 5)
  847. {
  848. Debug.LogWarning("UpdateArchive to 5");
  849. To5(nativeDoc, defaultDoc);
  850. }
  851. if (nativeVersion < 6)
  852. {
  853. Debug.LogWarning("UpdateArchive to 6");
  854. To6(nativeDoc, defaultDoc);
  855. }
  856. if (nativeVersion < 7)
  857. {
  858. Debug.LogWarning("UpdateArchive to 7");
  859. To7(nativeDoc, defaultDoc);
  860. }
  861. if (nativeVersion < 8)
  862. {
  863. Debug.LogWarning("UpdateArchive to 8");
  864. To8(nativeDoc, defaultDoc);
  865. }
  866. return nativeDoc;
  867. }
  868. public static XmlDocument To0(XmlDocument nativeDoc, XmlDocument defaultDoc)
  869. {
  870. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 0.ToString();
  871. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("ADPlayTime");
  872. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  873. return nativeDoc;
  874. }
  875. public static XmlDocument To1(XmlDocument nativeDoc, XmlDocument defaultDoc)
  876. {
  877. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 1.ToString();
  878. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("SerialNumber");
  879. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  880. return nativeDoc;
  881. }
  882. public static XmlDocument To2(XmlDocument nativeDoc, XmlDocument defaultDoc)
  883. {
  884. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 2.ToString();
  885. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NotificationIndex");
  886. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  887. return nativeDoc;
  888. }
  889. public static XmlDocument To3(XmlDocument nativeDoc, XmlDocument defaultDoc)
  890. {
  891. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 3.ToString();
  892. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NickName");
  893. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  894. return nativeDoc;
  895. }
  896. public static XmlDocument To4(XmlDocument nativeDoc, XmlDocument defaultDoc)
  897. {
  898. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 4.ToString();
  899. XmlNode xmlNode = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
  900. XmlAttribute attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftLongSleeveSlot"));
  901. attribute.Value="Empty";
  902. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftShortSleeveSlot"));
  903. attribute.Value="Empty";
  904. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightLongSleeveSlot"));
  905. attribute.Value="Empty";
  906. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightShortSleeveSlot"));
  907. attribute.Value="Empty";
  908. List<string> sleeveList = GetSleeveListByTop (xmlNode.Attributes [4].Value);
  909. xmlNode.Attributes [8].Value = sleeveList[0];
  910. xmlNode.Attributes [9].Value = sleeveList[1];
  911. xmlNode.Attributes [10].Value = sleeveList[2];
  912. xmlNode.Attributes [11].Value = sleeveList[3];
  913. return nativeDoc;
  914. }
  915. public static List<string> GetSleeveListByTop(string topName)
  916. {
  917. List<string> sleeveList = new List<string>() {"Empty", "Empty", "Empty", "Empty"};
  918. if (topName == "上衣1")
  919. {
  920. sleeveList[1] = "短袖1左";
  921. sleeveList[3] = "短袖1右";
  922. }
  923. else if (topName == "上衣2")
  924. {
  925. sleeveList[1] = "短袖2左";
  926. sleeveList[3] = "短袖2右";
  927. }
  928. else if (topName == "上衣3")
  929. {
  930. sleeveList[1] = "短袖2左";
  931. sleeveList[3] = "短袖2右";
  932. }
  933. else if (topName == "上衣5")
  934. {
  935. sleeveList[1] = "短袖2左";
  936. sleeveList[3] = "短袖2右";
  937. }
  938. else if (topName == "上衣6")
  939. {
  940. sleeveList[1] = "短袖6左";
  941. sleeveList[3] = "短袖6右";
  942. }
  943. else if (topName == "上衣7")
  944. {
  945. sleeveList[1] = "短袖7左";
  946. sleeveList[3] = "短袖7右";
  947. }
  948. else if (topName == "上衣7(粉)")
  949. {
  950. sleeveList[1] = "短袖7粉左";
  951. sleeveList[3] = "短袖7粉右";
  952. }
  953. else if (topName == "上衣12")
  954. {
  955. sleeveList[1] = "短袖12左";
  956. sleeveList[3] = "短袖12右";
  957. }
  958. else if (topName == "上衣13")
  959. {
  960. sleeveList[1] = "短袖13左";
  961. sleeveList[3] = "短袖13右";
  962. }
  963. else if (topName == "上衣13(紫)")
  964. {
  965. sleeveList[1] = "短袖13蓝左";
  966. sleeveList[3] = "短袖13蓝右";
  967. }
  968. else
  969. {
  970. sleeveList[0] = "长袖9左";
  971. sleeveList[2] = "长袖9右";
  972. }
  973. return sleeveList;
  974. }
  975. public static XmlDocument To5(XmlDocument nativeDoc, XmlDocument defaultDoc)
  976. {
  977. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 5.ToString();
  978. return nativeDoc;
  979. }
  980. public static XmlDocument To6(XmlDocument nativeDoc, XmlDocument defaultDoc)
  981. {
  982. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 6.ToString();
  983. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NewFlowerFlag");
  984. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  985. return nativeDoc;
  986. }
  987. public static XmlDocument To7(XmlDocument nativeDoc, XmlDocument defaultDoc)
  988. {
  989. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 7.ToString();
  990. XmlNode xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerList");
  991. string[] flowerIDs= xmlNode1.Attributes[0].Value.Split(' ');
  992. xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerAmtList");
  993. xmlNode1.Attributes[0].Value = "";
  994. foreach (var flowerID in flowerIDs)
  995. {
  996. xmlNode1.Attributes[0].Value += " " + "1";
  997. }
  998. xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
  999. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1000. return nativeDoc;
  1001. }
  1002. public static XmlDocument To8(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1003. {
  1004. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 8.ToString();
  1005. XmlNode xmlNode0 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialPlazaRoom");
  1006. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexPlazaRoom");
  1007. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode0, true));
  1008. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1009. return nativeDoc;
  1010. }
  1011. }