ManaData.cs 48 KB

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