ManaData.cs 49 KB

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