ManaData.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487
  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(List<string> dressdataNames)
  529. {
  530. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  531. //{
  532. // Debug.LogWarning(VARIABLE.Key);
  533. //}
  534. List<int> dressDataIDs = new List<int>();
  535. int index = 0;
  536. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  537. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  538. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  539. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  540. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  541. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  542. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  543. dressDataIDs.Add(ManaPlayer.CloseIDDic[dressdataNames[index++]]);
  544. return dressDataIDs;
  545. }
  546. public static List<int> GetDressDataIDs(ISFSObject parameter)
  547. {
  548. List<int> ids = parameter.GetIntArray(InfoLabel.Close.GetHashString()).ToList();
  549. return ids;
  550. }
  551. public static List<string> GetDressData(SFSObject parameter)
  552. {
  553. List<int> ids = GetDressDataIDs(parameter);
  554. List<string> dressData = new List<string>();
  555. foreach (var id in ids)
  556. {
  557. dressData.Add(ManaPlayer.CloseUnitDic[id].ArmatureName);
  558. }
  559. return dressData;
  560. }
  561. public static List<string> GetDressData(XmlNode node = null)
  562. {
  563. XmlNode xmlNode;
  564. if (node == null)
  565. {
  566. xmlNode = PlayerNode.SelectSingleNode("DressData");
  567. }
  568. else
  569. {
  570. xmlNode = node.SelectSingleNode("DressData");
  571. }
  572. List<string> dataList = new List<string>();
  573. if (xmlNode != null && xmlNode.Attributes.Count == 12)
  574. {
  575. dataList.Add(xmlNode.Attributes[0].Value);
  576. dataList.Add(xmlNode.Attributes[1].Value);
  577. dataList.Add(xmlNode.Attributes[2].Value);
  578. dataList.Add(xmlNode.Attributes[3].Value);
  579. dataList.Add(xmlNode.Attributes[4].Value);
  580. dataList.Add(xmlNode.Attributes[5].Value);
  581. dataList.Add(xmlNode.Attributes[6].Value);
  582. dataList.Add(xmlNode.Attributes[7].Value);
  583. dataList.Add(xmlNode.Attributes[8].Value);
  584. dataList.Add(xmlNode.Attributes[9].Value);
  585. dataList.Add(xmlNode.Attributes[10].Value);
  586. dataList.Add(xmlNode.Attributes[11].Value);
  587. //dataList[8] = "长袖9左";
  588. //dataList[9] = "Empty";
  589. //dataList[10] = "长袖9右";
  590. //dataList[11] = "Empty";
  591. }
  592. else if(xmlNode != null && xmlNode.Attributes.Count == 8)
  593. {
  594. dataList.Add(xmlNode.Attributes[0].Value);
  595. dataList.Add(xmlNode.Attributes[1].Value);
  596. dataList.Add(xmlNode.Attributes[2].Value);
  597. dataList.Add(xmlNode.Attributes[3].Value);
  598. dataList.Add(xmlNode.Attributes[4].Value);
  599. dataList.Add(xmlNode.Attributes[5].Value);
  600. dataList.Add(xmlNode.Attributes[6].Value);
  601. dataList.Add(xmlNode.Attributes[7].Value);
  602. dataList.AddRange (GetSleeveListByTop(xmlNode.Attributes[4].Value));
  603. }
  604. else
  605. {
  606. float rate = Random.Range(0f, 1f);
  607. if (rate < 0.33f)
  608. {
  609. dataList.Add("脑壳1");
  610. dataList.Add("裙子1");
  611. dataList.Add("鞋子1");
  612. dataList.Add("头饰品1");
  613. dataList.Add("上衣1");
  614. dataList.Add("眼睛1");
  615. dataList.Add("嘴巴1");
  616. dataList.Add("Empty");
  617. dataList.Add("Empty");
  618. dataList.Add("短袖1左");
  619. dataList.Add("Empty");
  620. dataList.Add("短袖1右");
  621. }
  622. else if (rate < 0.66f)
  623. {
  624. dataList.Add("脑壳2");
  625. dataList.Add("裙子2");
  626. dataList.Add("鞋子2");
  627. dataList.Add("头饰品2");
  628. dataList.Add("上衣2");
  629. dataList.Add("眼睛2");
  630. dataList.Add("嘴巴2");
  631. dataList.Add("Empty");
  632. dataList.Add("Empty");
  633. dataList.Add("短袖2左");
  634. dataList.Add("Empty");
  635. dataList.Add("短袖2右");
  636. }
  637. else
  638. {
  639. dataList.Add("脑壳3");
  640. dataList.Add("裙子3");
  641. dataList.Add("鞋子3");
  642. dataList.Add("头饰品3");
  643. dataList.Add("上衣3");
  644. dataList.Add("眼睛3");
  645. dataList.Add("嘴巴3");
  646. dataList.Add("Empty");
  647. dataList.Add("Empty");
  648. dataList.Add("短袖2左");
  649. dataList.Add("Empty");
  650. dataList.Add("短袖2右");
  651. }
  652. }
  653. return dataList;
  654. }
  655. public static List<int> GetFlowerList()
  656. {
  657. List<int> list = new List<int>();
  658. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  659. return Auxiliary.IntListParse(' ', attribute[0].Value, list);
  660. }
  661. public static List<int> GetAchieveList()
  662. {
  663. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  664. }
  665. public static List<string> GetOfflineConfig()
  666. {
  667. TextAsset textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
  668. XmlDocument xmlDoc = new XmlDocument();
  669. xmlDoc.LoadXml(textAsset.text);
  670. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  671. List<string> strList = new List<string>()
  672. {
  673. xmlNode.Attributes[1].Value,
  674. xmlNode.Attributes[2].Value,
  675. xmlNode.Attributes[3].Value,
  676. };
  677. return strList;
  678. }
  679. public static List<double> GetAchieveData()
  680. {
  681. List<double> dataList = new List<double>();
  682. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  683. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  684. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  685. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  686. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  687. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  688. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  689. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
  690. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value));
  691. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[9].Value));
  692. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[10].Value));
  693. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[11].Value));
  694. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[12].Value));
  695. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[13].Value));
  696. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[14].Value));
  697. return dataList;
  698. }
  699. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  700. {
  701. List<KV<int, int>> list = new List<KV<int, int>>();
  702. XmlNode xmlNode;
  703. if (node == null)
  704. {
  705. xmlNode = PlayerNode.SelectSingleNode("PlantList");
  706. }
  707. else
  708. {
  709. xmlNode = node.SelectSingleNode("PlantList");
  710. }
  711. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  712. {
  713. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  714. for (int i = 0; i < strings.Length; i++)
  715. {
  716. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  717. }
  718. }
  719. return list;
  720. }
  721. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  722. {
  723. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  724. XmlNodeList xmlNodeList;
  725. if (node == null)
  726. {
  727. xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  728. }
  729. else
  730. {
  731. xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
  732. }
  733. for (int i = 0; i < xmlNodeList.Count; i++)
  734. {
  735. attributeList.Add(xmlNodeList[i].Attributes);
  736. }
  737. return attributeList;
  738. }
  739. public static XmlAttributeCollection GetVisitConfig()
  740. {
  741. TextAsset textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
  742. XmlDocument xmlDoc = new XmlDocument();
  743. xmlDoc.LoadXml(textAsset.text);
  744. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  745. return xmlNode.Attributes;
  746. }
  747. public static XmlAttributeCollection GetPlazaRoomConfig()
  748. {
  749. TextAsset textAsset = ManaReso.Load<TextAsset>("plaza_room_config", Folder.Config);
  750. XmlDocument xmlDoc = new XmlDocument();
  751. xmlDoc.LoadXml(textAsset.text);
  752. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  753. return xmlNode.Attributes;
  754. }
  755. public static XmlAttributeCollection GetAwardConfig()
  756. {
  757. TextAsset textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
  758. XmlDocument xmlDoc = new XmlDocument();
  759. xmlDoc.LoadXml(textAsset.text);
  760. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  761. return xmlNode.Attributes;
  762. }
  763. public static List<XmlAttributeCollection> GetIAPConfig()
  764. {
  765. TextAsset textAsset;
  766. XmlNodeList xmlNodeList;
  767. XmlDocument xmlDoc = new XmlDocument();
  768. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  769. textAsset = ManaReso.Load<TextAsset>("iap_config", Folder.Config);
  770. xmlDoc.LoadXml(textAsset.text);
  771. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  772. for (int i = 0; i < xmlNodeList.Count; i++)
  773. {
  774. attributeList.Add(xmlNodeList[i].Attributes);
  775. }
  776. return attributeList;
  777. }
  778. public static List<XmlAttributeCollection> GetSkillConfig()
  779. {
  780. TextAsset textAsset;
  781. XmlDocument xmlDoc = new XmlDocument();
  782. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  783. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  784. textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
  785. xmlDoc.LoadXml(textAsset.text);
  786. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  787. textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
  788. xmlDoc.LoadXml(textAsset.text);
  789. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  790. textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
  791. xmlDoc.LoadXml(textAsset.text);
  792. xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  793. for (int i = 0; i < xmlNodeList.Count; i++)
  794. {
  795. for (int j = 0; j < xmlNodeList[i].Count; j++)
  796. {
  797. attributeList.Add(xmlNodeList[i][j].Attributes);
  798. }
  799. }
  800. return attributeList;
  801. }
  802. public static List<XmlAttributeCollection> GetSignConfig()
  803. {
  804. TextAsset textAsset;
  805. XmlNodeList xmlNodeList;
  806. XmlDocument xmlDoc = new XmlDocument();
  807. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  808. textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
  809. xmlDoc.LoadXml(textAsset.text);
  810. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  811. for (int i = 0; i < xmlNodeList.Count; i++)
  812. {
  813. attributeList.Add(xmlNodeList[i].Attributes);
  814. }
  815. return attributeList;
  816. }
  817. public static List<XmlAttributeCollection> GetFlowerConfig()
  818. {
  819. TextAsset textAsset;
  820. XmlNodeList xmlNodeList;
  821. XmlDocument xmlDoc = new XmlDocument();
  822. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  823. textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
  824. xmlDoc.LoadXml(textAsset.text);
  825. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  826. for (int i = 0; i < xmlNodeList.Count; i++)
  827. {
  828. attributeList.Add(xmlNodeList[i].Attributes);
  829. }
  830. return attributeList;
  831. }
  832. public static List<XmlAttributeCollection> GetLotteryConfig()
  833. {
  834. TextAsset textAsset;
  835. XmlNodeList xmlNodeList;
  836. XmlDocument xmlDoc = new XmlDocument();
  837. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  838. textAsset = ManaReso.Load<TextAsset>("lottery_config", Folder.Config);
  839. xmlDoc.LoadXml(textAsset.text);
  840. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  841. for (int i = 0; i < xmlNodeList.Count; i++)
  842. {
  843. attributeList.Add(xmlNodeList[i].Attributes);
  844. }
  845. return attributeList;
  846. }
  847. public static List<XmlAttributeCollection> GetAchieveConfig()
  848. {
  849. TextAsset textAsset;
  850. XmlNodeList xmlNodeList;
  851. XmlDocument xmlDoc = new XmlDocument();
  852. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  853. textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
  854. xmlDoc.LoadXml(textAsset.text);
  855. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  856. for (int i = 0; i < xmlNodeList.Count; i++)
  857. {
  858. attributeList.Add(xmlNodeList[i].Attributes);
  859. }
  860. return attributeList;
  861. }
  862. public static List<XmlAttributeCollection> GetDressRoomConfig()
  863. {
  864. TextAsset textAsset;
  865. XmlNodeList xmlNodeList;
  866. XmlDocument xmlDoc = new XmlDocument();
  867. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  868. textAsset = ManaReso.Load<TextAsset>("dressRoom_config", Folder.Config);
  869. xmlDoc.LoadXml(textAsset.text);
  870. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  871. for (int i = 0; i < xmlNodeList.Count; i++)
  872. {
  873. attributeList.Add(xmlNodeList[i].Attributes);
  874. }
  875. return attributeList;
  876. }
  877. public static XmlDocument GetXmlDocument(string ConfigName)
  878. {
  879. TextAsset textAsset = ManaReso.Load<TextAsset>(ConfigName, Folder.Config);
  880. XmlDocument xmlDocument = new XmlDocument();
  881. xmlDocument.LoadXml(textAsset.text);
  882. return xmlDocument;
  883. }
  884. //玩家存档版本大于默认存档版本时需要清空
  885. //玩家存档版本小于默认存档版本时需要合并
  886. //玩家存档版本等于-1000时需要标记为重玩
  887. public static XmlDocument MergeXML(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  888. {
  889. if (nativeVersion < 0)
  890. {
  891. Debug.LogWarning("UpdateArchive to 0");
  892. To0(nativeDoc, defaultDoc);
  893. }
  894. if (nativeVersion < 1)
  895. {
  896. Debug.LogWarning("UpdateArchive to 1");
  897. To1(nativeDoc, defaultDoc);
  898. }
  899. if (nativeVersion < 2)
  900. {
  901. Debug.LogWarning("UpdateArchive to 2");
  902. To2(nativeDoc, defaultDoc);
  903. }
  904. if (nativeVersion < 3)
  905. {
  906. Debug.LogWarning("UpdateArchive to 3");
  907. To3(nativeDoc, defaultDoc);
  908. }
  909. if (nativeVersion < 4)
  910. {
  911. Debug.LogWarning("UpdateArchive to 4");
  912. To4(nativeDoc, defaultDoc);
  913. }
  914. if (nativeVersion < 5)
  915. {
  916. Debug.LogWarning("UpdateArchive to 5");
  917. To5(nativeDoc, defaultDoc);
  918. }
  919. if (nativeVersion < 6)
  920. {
  921. Debug.LogWarning("UpdateArchive to 6");
  922. To6(nativeDoc, defaultDoc);
  923. }
  924. if (nativeVersion < 7)
  925. {
  926. Debug.LogWarning("UpdateArchive to 7");
  927. To7(nativeDoc, defaultDoc);
  928. }
  929. if (nativeVersion < 8)
  930. {
  931. Debug.LogWarning("UpdateArchive to 8");
  932. To8(nativeDoc, defaultDoc);
  933. }
  934. if (nativeVersion < 9)
  935. {
  936. Debug.LogWarning("UpdateArchive to 9");
  937. To9(nativeDoc, defaultDoc);
  938. }
  939. if (nativeVersion < 10)
  940. {
  941. Debug.LogWarning("UpdateArchive to 10");
  942. To10(nativeDoc, defaultDoc);
  943. }
  944. if (nativeVersion < 11)
  945. {
  946. Debug.LogWarning("UpdateArchive to 11");
  947. To11(nativeDoc, defaultDoc);
  948. }
  949. return nativeDoc;
  950. }
  951. public static XmlDocument To0(XmlDocument nativeDoc, XmlDocument defaultDoc)
  952. {
  953. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 0.ToString();
  954. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("ADPlayTime");
  955. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  956. return nativeDoc;
  957. }
  958. public static XmlDocument To1(XmlDocument nativeDoc, XmlDocument defaultDoc)
  959. {
  960. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 1.ToString();
  961. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("SerialNumber");
  962. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  963. return nativeDoc;
  964. }
  965. public static XmlDocument To2(XmlDocument nativeDoc, XmlDocument defaultDoc)
  966. {
  967. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 2.ToString();
  968. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NotificationIndex");
  969. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  970. return nativeDoc;
  971. }
  972. public static XmlDocument To3(XmlDocument nativeDoc, XmlDocument defaultDoc)
  973. {
  974. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 3.ToString();
  975. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NickName");
  976. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  977. return nativeDoc;
  978. }
  979. public static XmlDocument To4(XmlDocument nativeDoc, XmlDocument defaultDoc)
  980. {
  981. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 4.ToString();
  982. XmlNode xmlNode = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
  983. XmlAttribute attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftLongSleeveSlot"));
  984. attribute.Value="Empty";
  985. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("LeftShortSleeveSlot"));
  986. attribute.Value="Empty";
  987. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightLongSleeveSlot"));
  988. attribute.Value="Empty";
  989. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute ("RightShortSleeveSlot"));
  990. attribute.Value="Empty";
  991. List<string> sleeveList = GetSleeveListByTop (xmlNode.Attributes [4].Value);
  992. xmlNode.Attributes [8].Value = sleeveList[0];
  993. xmlNode.Attributes [9].Value = sleeveList[1];
  994. xmlNode.Attributes [10].Value = sleeveList[2];
  995. xmlNode.Attributes [11].Value = sleeveList[3];
  996. return nativeDoc;
  997. }
  998. public static List<string> GetSleeveListByTop(string topName)
  999. {
  1000. List<string> sleeveList = new List<string>() {"Empty", "Empty", "Empty", "Empty"};
  1001. if (topName == "上衣1")
  1002. {
  1003. sleeveList[1] = "短袖1左";
  1004. sleeveList[3] = "短袖1右";
  1005. }
  1006. else if (topName == "上衣2")
  1007. {
  1008. sleeveList[1] = "短袖2左";
  1009. sleeveList[3] = "短袖2右";
  1010. }
  1011. else if (topName == "上衣3")
  1012. {
  1013. sleeveList[1] = "短袖2左";
  1014. sleeveList[3] = "短袖2右";
  1015. }
  1016. else if (topName == "上衣5")
  1017. {
  1018. sleeveList[1] = "短袖2左";
  1019. sleeveList[3] = "短袖2右";
  1020. }
  1021. else if (topName == "上衣6")
  1022. {
  1023. sleeveList[1] = "短袖6左";
  1024. sleeveList[3] = "短袖6右";
  1025. }
  1026. else if (topName == "上衣7")
  1027. {
  1028. sleeveList[1] = "短袖7左";
  1029. sleeveList[3] = "短袖7右";
  1030. }
  1031. else if (topName == "上衣7(粉)")
  1032. {
  1033. sleeveList[1] = "短袖7粉左";
  1034. sleeveList[3] = "短袖7粉右";
  1035. }
  1036. else if (topName == "上衣12")
  1037. {
  1038. sleeveList[1] = "短袖12左";
  1039. sleeveList[3] = "短袖12右";
  1040. }
  1041. else if (topName == "上衣13")
  1042. {
  1043. sleeveList[1] = "短袖13左";
  1044. sleeveList[3] = "短袖13右";
  1045. }
  1046. else if (topName == "上衣13(紫)")
  1047. {
  1048. sleeveList[1] = "短袖13蓝左";
  1049. sleeveList[3] = "短袖13蓝右";
  1050. }
  1051. else
  1052. {
  1053. sleeveList[0] = "长袖9左";
  1054. sleeveList[2] = "长袖9右";
  1055. }
  1056. return sleeveList;
  1057. }
  1058. public static XmlDocument To5(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1059. {
  1060. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 5.ToString();
  1061. return nativeDoc;
  1062. }
  1063. public static XmlDocument To6(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1064. {
  1065. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 6.ToString();
  1066. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("NewFlowerFlag");
  1067. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1068. return nativeDoc;
  1069. }
  1070. public static XmlDocument To7(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1071. {
  1072. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 7.ToString();
  1073. XmlNode xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerList");
  1074. string[] flowerIDs= xmlNode1.Attributes[0].Value.Split(' ');
  1075. xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("FlowerAmtList");
  1076. xmlNode1.Attributes[0].Value = "";
  1077. foreach (var flowerID in flowerIDs)
  1078. {
  1079. xmlNode1.Attributes[0].Value += " " + "1";
  1080. }
  1081. xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
  1082. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1083. return nativeDoc;
  1084. }
  1085. public static XmlDocument To8(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1086. {
  1087. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 8.ToString();
  1088. XmlNode xmlNode0 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialPlazaRoom");
  1089. XmlNode xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexPlazaRoom");
  1090. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode0, true));
  1091. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1092. return nativeDoc;
  1093. }
  1094. public static XmlDocument To9(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1095. {
  1096. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 9.ToString();
  1097. XmlNode xmlNode = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("AchieveData");
  1098. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("CreateRoomAmt"));
  1099. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("CreateChestAmt"));
  1100. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("CreateLuckyChestAmt"));
  1101. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("CreateGuessColorChestAmt"));
  1102. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("CreateGuessNumberChestAmt"));
  1103. xmlNode.Attributes.Append(nativeDoc.CreateAttribute("GetChestAwardAmt"));
  1104. xmlNode.Attributes[9].Value = "0";
  1105. xmlNode.Attributes[10].Value = "0";
  1106. xmlNode.Attributes[11].Value = "0";
  1107. xmlNode.Attributes[12].Value = "0";
  1108. xmlNode.Attributes[13].Value = "0";
  1109. xmlNode.Attributes[14].Value = "0";
  1110. return nativeDoc;
  1111. }
  1112. public static XmlDocument To10(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1113. {
  1114. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 10.ToString();
  1115. ChestMge.ClearRefundAndOperateData(nativeDoc.SelectSingleNode("PlayerConfig"));
  1116. return nativeDoc;
  1117. }
  1118. public static XmlDocument To11(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1119. {
  1120. nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 11.ToString();
  1121. XmlNode xmlNode = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("ReplayVersion");
  1122. nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1123. return nativeDoc;
  1124. }
  1125. }