ManaData.cs 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  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. }
  415. }
  416. public static void ResetPlayerConfig()
  417. {
  418. PlayerNode.SelectSingleNode("Version").Attributes[0].Value = "10000";
  419. SavePlayerConfig();
  420. ManaCenter.SaveLock = true;
  421. }
  422. public static int GetPlayerInt(string node)
  423. {
  424. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  425. }
  426. public static bool GetPlayerBool(string node)
  427. {
  428. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
  429. }
  430. public static float GetPlayerFloat(string node)
  431. {
  432. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  433. }
  434. public static string GetPlayerString(string node)
  435. {
  436. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  437. }
  438. public static double GetPlayerDouble(string node)
  439. {
  440. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  441. }
  442. public static void SavePlayerInt(string node, int value)
  443. {
  444. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  445. }
  446. public static void SavePlayerBool(string node, bool value)
  447. {
  448. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
  449. }
  450. public static void SavePlayerFloat(string node, float value)
  451. {
  452. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  453. }
  454. public static void SavePlayerString(string node, string value)
  455. {
  456. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  457. }
  458. public static void SavePlayerDouble(string node, double value)
  459. {
  460. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  461. }
  462. public static List<int> GetIntList(char splitChar, string nodeName, List<int> defaultList)
  463. {
  464. return Auxiliary.IntListParse(splitChar, PlayerNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  465. }
  466. public static List<string> GetStringList(char splitChar, string nodeName, List<string> defaultList)
  467. {
  468. return Auxiliary.StringListParse(splitChar, PlayerNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  469. }
  470. public static List<int> GetDressList()
  471. {
  472. List<int> list = new List<int>();
  473. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("DressList").Attributes;
  474. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  475. }
  476. public static List<int> GetDressDataIDs(Player player)
  477. {
  478. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  479. //{
  480. // Debug.LogWarning(VARIABLE.Key);
  481. //}
  482. List<int> dressDataIDs = new List<int>();
  483. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Head]);
  484. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Dress]);
  485. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Shoe]);
  486. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.HeadWear]);
  487. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Top]);
  488. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Eye]);
  489. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Mouse]);
  490. dressDataIDs.Add(ManaPlayer.CloseIDDic[player.Wing]);
  491. return dressDataIDs;
  492. }
  493. public static List<int> GetDressDataIDs(SFSObject parameter)
  494. {
  495. List<int> ids = parameter.GetIntArray(DataID.Close.GetHashString()).ToList();
  496. return ids;
  497. }
  498. public static List<string> GetDressData(SFSObject parameter)
  499. {
  500. List<int> ids = GetDressDataIDs(parameter);
  501. List<string> dressData = new List<string>();
  502. foreach (var id in ids)
  503. {
  504. dressData.Add(ManaPlayer.CloseUnitDic[id].ArmatureName);
  505. }
  506. return dressData;
  507. }
  508. public static List<string> GetDressData(XmlNode node = null)
  509. {
  510. XmlNode xmlNode;
  511. if (node == null)
  512. {
  513. xmlNode = PlayerNode.SelectSingleNode("DressData");
  514. }
  515. else
  516. {
  517. xmlNode = node.SelectSingleNode("DressData");
  518. }
  519. List<string> dataList = new List<string>();
  520. if (xmlNode != null && xmlNode.Attributes.Count == 12)
  521. {
  522. dataList.Add(xmlNode.Attributes[0].Value);
  523. dataList.Add(xmlNode.Attributes[1].Value);
  524. dataList.Add(xmlNode.Attributes[2].Value);
  525. dataList.Add(xmlNode.Attributes[3].Value);
  526. dataList.Add(xmlNode.Attributes[4].Value);
  527. dataList.Add(xmlNode.Attributes[5].Value);
  528. dataList.Add(xmlNode.Attributes[6].Value);
  529. dataList.Add(xmlNode.Attributes[7].Value);
  530. dataList.Add(xmlNode.Attributes[8].Value);
  531. dataList.Add(xmlNode.Attributes[9].Value);
  532. dataList.Add(xmlNode.Attributes[10].Value);
  533. dataList.Add(xmlNode.Attributes[11].Value);
  534. //dataList[8] = "长袖9左";
  535. //dataList[9] = "Empty";
  536. //dataList[10] = "长袖9右";
  537. //dataList[11] = "Empty";
  538. }
  539. else if(xmlNode != null && xmlNode.Attributes.Count == 8)
  540. {
  541. dataList.Add(xmlNode.Attributes[0].Value);
  542. dataList.Add(xmlNode.Attributes[1].Value);
  543. dataList.Add(xmlNode.Attributes[2].Value);
  544. dataList.Add(xmlNode.Attributes[3].Value);
  545. dataList.Add(xmlNode.Attributes[4].Value);
  546. dataList.Add(xmlNode.Attributes[5].Value);
  547. dataList.Add(xmlNode.Attributes[6].Value);
  548. dataList.Add(xmlNode.Attributes[7].Value);
  549. dataList.AddRange (GetSleeveListByTop(xmlNode.Attributes[4].Value));
  550. }
  551. else
  552. {
  553. float rate = Random.Range(0f, 1f);
  554. if (rate < 0.33f)
  555. {
  556. dataList.Add("脑壳1");
  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("Empty");
  564. dataList.Add("Empty");
  565. dataList.Add("短袖1左");
  566. dataList.Add("Empty");
  567. dataList.Add("短袖1右");
  568. }
  569. else if (rate < 0.66f)
  570. {
  571. dataList.Add("脑壳2");
  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("Empty");
  579. dataList.Add("Empty");
  580. dataList.Add("短袖2左");
  581. dataList.Add("Empty");
  582. dataList.Add("短袖2右");
  583. }
  584. else
  585. {
  586. dataList.Add("脑壳3");
  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("Empty");
  594. dataList.Add("Empty");
  595. dataList.Add("短袖2左");
  596. dataList.Add("Empty");
  597. dataList.Add("短袖2右");
  598. }
  599. }
  600. return dataList;
  601. }
  602. public static List<int> GetFlowerList()
  603. {
  604. List<int> list = new List<int>();
  605. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  606. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  607. }
  608. public static List<int> GetAchieveList()
  609. {
  610. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  611. }
  612. public static List<string> GetOfflineConfig()
  613. {
  614. TextAsset textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
  615. XmlDocument xmlDoc = new XmlDocument();
  616. xmlDoc.LoadXml(textAsset.text);
  617. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  618. List<string> strList = new List<string>()
  619. {
  620. xmlNode.Attributes[1].Value,
  621. xmlNode.Attributes[2].Value,
  622. xmlNode.Attributes[3].Value,
  623. };
  624. return strList;
  625. }
  626. public static List<double> GetAchieveData()
  627. {
  628. List<double> dataList = new List<double>();
  629. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  630. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  631. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  632. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  633. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  634. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  635. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  636. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
  637. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value));
  638. return dataList;
  639. }
  640. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  641. {
  642. List<KV<int, int>> list = new List<KV<int, int>>();
  643. XmlNode xmlNode;
  644. if (node == null)
  645. {
  646. xmlNode = PlayerNode.SelectSingleNode("PlantList");
  647. }
  648. else
  649. {
  650. xmlNode = node.SelectSingleNode("PlantList");
  651. }
  652. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  653. {
  654. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  655. for (int i = 0; i < strings.Length; i++)
  656. {
  657. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  658. }
  659. }
  660. return list;
  661. }
  662. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  663. {
  664. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  665. XmlNodeList xmlNodeList;
  666. if (node == null)
  667. {
  668. xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  669. }
  670. else
  671. {
  672. xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
  673. }
  674. for (int i = 0; i < xmlNodeList.Count; i++)
  675. {
  676. attributeList.Add(xmlNodeList[i].Attributes);
  677. }
  678. return attributeList;
  679. }
  680. public static XmlAttributeCollection GetVisitConfig()
  681. {
  682. TextAsset textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
  683. XmlDocument xmlDoc = new XmlDocument();
  684. xmlDoc.LoadXml(textAsset.text);
  685. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  686. return xmlNode.Attributes;
  687. }
  688. public static XmlAttributeCollection GetPlazaRoomConfig()
  689. {
  690. TextAsset textAsset = ManaReso.Load<TextAsset>("plaza_room_config", Folder.Config);
  691. XmlDocument xmlDoc = new XmlDocument();
  692. xmlDoc.LoadXml(textAsset.text);
  693. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  694. return xmlNode.Attributes;
  695. }
  696. public static XmlAttributeCollection GetAwardConfig()
  697. {
  698. TextAsset textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
  699. XmlDocument xmlDoc = new XmlDocument();
  700. xmlDoc.LoadXml(textAsset.text);
  701. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  702. return xmlNode.Attributes;
  703. }
  704. public static List<XmlAttributeCollection> GetIAPConfig()
  705. {
  706. TextAsset textAsset;
  707. XmlNodeList xmlNodeList;
  708. XmlDocument xmlDoc = new XmlDocument();
  709. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  710. textAsset = ManaReso.Load<TextAsset>("iap_config", Folder.Config);
  711. xmlDoc.LoadXml(textAsset.text);
  712. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  713. for (int i = 0; i < xmlNodeList.Count; i++)
  714. {
  715. attributeList.Add(xmlNodeList[i].Attributes);
  716. }
  717. return attributeList;
  718. }
  719. public static List<XmlAttributeCollection> GetSkillConfig()
  720. {
  721. TextAsset textAsset;
  722. XmlDocument xmlDoc = new XmlDocument();
  723. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  724. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  725. textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
  726. xmlDoc.LoadXml(textAsset.text);
  727. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  728. textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
  729. xmlDoc.LoadXml(textAsset.text);
  730. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  731. textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
  732. xmlDoc.LoadXml(textAsset.text);
  733. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  734. for (int i = 0; i < xmlNodeList.Count; i++)
  735. {
  736. for (int j = 0; j < xmlNodeList[i].Count; j++)
  737. {
  738. attributeList.Add(xmlNodeList[i][j].Attributes);
  739. }
  740. }
  741. return attributeList;
  742. }
  743. public static List<XmlAttributeCollection> GetSignConfig()
  744. {
  745. TextAsset textAsset;
  746. XmlNodeList xmlNodeList;
  747. XmlDocument xmlDoc = new XmlDocument();
  748. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  749. textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
  750. xmlDoc.LoadXml(textAsset.text);
  751. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  752. for (int i = 0; i < xmlNodeList.Count; i++)
  753. {
  754. attributeList.Add(xmlNodeList[i].Attributes);
  755. }
  756. return attributeList;
  757. }
  758. public static List<XmlAttributeCollection> GetFlowerConfig()
  759. {
  760. TextAsset textAsset;
  761. XmlNodeList xmlNodeList;
  762. XmlDocument xmlDoc = new XmlDocument();
  763. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  764. textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
  765. xmlDoc.LoadXml(textAsset.text);
  766. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  767. for (int i = 0; i < xmlNodeList.Count; i++)
  768. {
  769. attributeList.Add(xmlNodeList[i].Attributes);
  770. }
  771. return attributeList;
  772. }
  773. public static List<XmlAttributeCollection> GetLotteryConfig()
  774. {
  775. TextAsset textAsset;
  776. XmlNodeList xmlNodeList;
  777. XmlDocument xmlDoc = new XmlDocument();
  778. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  779. textAsset = ManaReso.Load<TextAsset>("lottery_config", Folder.Config);
  780. xmlDoc.LoadXml(textAsset.text);
  781. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  782. for (int i = 0; i < xmlNodeList.Count; i++)
  783. {
  784. attributeList.Add(xmlNodeList[i].Attributes);
  785. }
  786. return attributeList;
  787. }
  788. public static List<XmlAttributeCollection> GetAchieveConfig()
  789. {
  790. TextAsset textAsset;
  791. XmlNodeList xmlNodeList;
  792. XmlDocument xmlDoc = new XmlDocument();
  793. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  794. textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
  795. xmlDoc.LoadXml(textAsset.text);
  796. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  797. for (int i = 0; i < xmlNodeList.Count; i++)
  798. {
  799. attributeList.Add(xmlNodeList[i].Attributes);
  800. }
  801. return attributeList;
  802. }
  803. public static List<XmlAttributeCollection> GetDressRoomConfig()
  804. {
  805. TextAsset textAsset;
  806. XmlNodeList xmlNodeList;
  807. XmlDocument xmlDoc = new XmlDocument();
  808. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  809. textAsset = ManaReso.Load<TextAsset>("dressRoom_config", Folder.Config);
  810. xmlDoc.LoadXml(textAsset.text);
  811. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  812. for (int i = 0; i < xmlNodeList.Count; i++)
  813. {
  814. attributeList.Add(xmlNodeList[i].Attributes);
  815. }
  816. return attributeList;
  817. }
  818. public static XmlDocument MergeXML(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  819. {
  820. if (nativeVersion < 0)
  821. {
  822. Debug.LogWarning("UpdateArchive to 0");
  823. To0(nativeDoc, defaultDoc);
  824. }
  825. if (nativeVersion < 1)
  826. {
  827. Debug.LogWarning("UpdateArchive to 1");
  828. To1(nativeDoc, defaultDoc);
  829. }
  830. if (nativeVersion < 2)
  831. {
  832. Debug.LogWarning("UpdateArchive to 2");
  833. To2(nativeDoc, defaultDoc);
  834. }
  835. if (nativeVersion < 3)
  836. {
  837. Debug.LogWarning("UpdateArchive to 3");
  838. To3(nativeDoc, defaultDoc);
  839. }
  840. if (nativeVersion < 4)
  841. {
  842. Debug.LogWarning("UpdateArchive to 4");
  843. To4(nativeDoc, defaultDoc);
  844. }
  845. if (nativeVersion < 5)
  846. {
  847. Debug.LogWarning("UpdateArchive to 5");
  848. To5(nativeDoc, defaultDoc);
  849. }
  850. if (nativeVersion < 6)
  851. {
  852. Debug.LogWarning("UpdateArchive to 6");
  853. To6(nativeDoc, defaultDoc);
  854. }
  855. if (nativeVersion < 7)
  856. {
  857. Debug.LogWarning("UpdateArchive to 7");
  858. To7(nativeDoc, defaultDoc);
  859. }
  860. if (nativeVersion < 8)
  861. {
  862. Debug.LogWarning("UpdateArchive to 8");
  863. To8(nativeDoc, defaultDoc);
  864. }
  865. return nativeDoc;
  866. }
  867. public static XmlDocument To0(XmlDocument nativeDoc, XmlDocument defaultDoc)
  868. {
  869. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 0.ToString();
  870. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("ADPlayTime");
  871. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  872. return nativeDoc;
  873. }
  874. public static XmlDocument To1(XmlDocument nativeDoc, XmlDocument defaultDoc)
  875. {
  876. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 1.ToString();
  877. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("SerialNumber");
  878. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  879. return nativeDoc;
  880. }
  881. public static XmlDocument To2(XmlDocument nativeDoc, XmlDocument defaultDoc)
  882. {
  883. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 2.ToString();
  884. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NotificationIndex");
  885. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  886. return nativeDoc;
  887. }
  888. public static XmlDocument To3(XmlDocument nativeDoc, XmlDocument defaultDoc)
  889. {
  890. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 3.ToString();
  891. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NickName");
  892. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  893. return nativeDoc;
  894. }
  895. public static XmlDocument To4(XmlDocument nativeDoc, XmlDocument defaultDoc)
  896. {
  897. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 4.ToString();
  898. XmlNode xmlNode = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
  899. XmlAttribute attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftLongSleeveSlot"));
  900. attribute.Value="Empty";
  901. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftShortSleeveSlot"));
  902. attribute.Value="Empty";
  903. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightLongSleeveSlot"));
  904. attribute.Value="Empty";
  905. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightShortSleeveSlot"));
  906. attribute.Value="Empty";
  907. List<string> sleeveList = GetSleeveListByTop (xmlNode.Attributes [4].Value);
  908. xmlNode.Attributes [8].Value = sleeveList[0];
  909. xmlNode.Attributes [9].Value = sleeveList[1];
  910. xmlNode.Attributes [10].Value = sleeveList[2];
  911. xmlNode.Attributes [11].Value = sleeveList[3];
  912. return nativeDoc;
  913. }
  914. public static List<string> GetSleeveListByTop(string topName)
  915. {
  916. List<string> sleeveList = new List<string>() {"Empty", "Empty", "Empty", "Empty"};
  917. if (topName == "上衣1")
  918. {
  919. sleeveList[1] = "短袖1左";
  920. sleeveList[3] = "短袖1右";
  921. }
  922. else if (topName == "上衣2")
  923. {
  924. sleeveList[1] = "短袖2左";
  925. sleeveList[3] = "短袖2右";
  926. }
  927. else if (topName == "上衣3")
  928. {
  929. sleeveList[1] = "短袖2左";
  930. sleeveList[3] = "短袖2右";
  931. }
  932. else if (topName == "上衣5")
  933. {
  934. sleeveList[1] = "短袖2左";
  935. sleeveList[3] = "短袖2右";
  936. }
  937. else if (topName == "上衣6")
  938. {
  939. sleeveList[1] = "短袖6左";
  940. sleeveList[3] = "短袖6右";
  941. }
  942. else if (topName == "上衣7")
  943. {
  944. sleeveList[1] = "短袖7左";
  945. sleeveList[3] = "短袖7右";
  946. }
  947. else if (topName == "上衣7(粉)")
  948. {
  949. sleeveList[1] = "短袖7粉左";
  950. sleeveList[3] = "短袖7粉右";
  951. }
  952. else if (topName == "上衣12")
  953. {
  954. sleeveList[1] = "短袖12左";
  955. sleeveList[3] = "短袖12右";
  956. }
  957. else if (topName == "上衣13")
  958. {
  959. sleeveList[1] = "短袖13左";
  960. sleeveList[3] = "短袖13右";
  961. }
  962. else if (topName == "上衣13(紫)")
  963. {
  964. sleeveList[1] = "短袖13蓝左";
  965. sleeveList[3] = "短袖13蓝右";
  966. }
  967. else
  968. {
  969. sleeveList[0] = "长袖9左";
  970. sleeveList[2] = "长袖9右";
  971. }
  972. return sleeveList;
  973. }
  974. public static XmlDocument To5(XmlDocument nativeDoc, XmlDocument defaultDoc)
  975. {
  976. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 5.ToString();
  977. return nativeDoc;
  978. }
  979. public static XmlDocument To6(XmlDocument nativeDoc, XmlDocument defaultDoc)
  980. {
  981. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 6.ToString();
  982. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NewFlowerFlag");
  983. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  984. return nativeDoc;
  985. }
  986. public static XmlDocument To7(XmlDocument nativeDoc, XmlDocument defaultDoc)
  987. {
  988. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 7.ToString();
  989. XmlNode xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerList");
  990. string[] flowerIDs= xmlNode1.Attributes[0].Value.Split(' ');
  991. xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerAmtList");
  992. xmlNode1.Attributes[0].Value = "";
  993. foreach (var flowerID in flowerIDs)
  994. {
  995. xmlNode1.Attributes[0].Value += " " + "1";
  996. }
  997. xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
  998. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  999. return nativeDoc;
  1000. }
  1001. public static XmlDocument To8(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1002. {
  1003. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 8.ToString();
  1004. XmlNode xmlNode0 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialPlazaRoom");
  1005. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexPlazaRoom");
  1006. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode0, true));
  1007. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1008. return nativeDoc;
  1009. }
  1010. }