ManaData.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  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(Lib.ConfigPrefs) != 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. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 11.ToString();
  1096. XmlNode xmlNode = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("ReplayVersion");
  1097. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1098. return nativeDoc;
  1099. }
  1100. }