ConfigManager.cs 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761
  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 UnityEngine.UI;
  14. using Random = UnityEngine.Random;
  15. public class ConfigManager : Regist
  16. {
  17. #region Config
  18. public static XmlNode ConfigRootNode
  19. {
  20. get
  21. {
  22. if (configRootNode == null)
  23. {
  24. configRootNode = ConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode);
  25. }
  26. return configRootNode;
  27. }
  28. set { configRootNode = value; }
  29. }
  30. public static XmlNode configRootNode;
  31. public static XmlDocument ConfigDocument
  32. {
  33. get
  34. {
  35. if (configDocument == null)
  36. {
  37. LoadConfigDocument();
  38. }
  39. return configDocument;
  40. }
  41. set { configDocument = value; }
  42. }
  43. public static XmlDocument configDocument;
  44. public static float UrlTimer;
  45. public static bool PlayerDocumentDamageFlag;
  46. public static bool IDRequestFlag;
  47. public static bool SerialNumberRequestFlag = true;
  48. public static XmlDocument DefaultConfigDocument = new XmlDocument();
  49. public static int ConfigReplayVersion = -1000;
  50. public static string ConfigPath
  51. {
  52. get
  53. {
  54. if (string.IsNullOrEmpty(configPath))
  55. {
  56. configPath = string.Format("{0}/{1}", Application.persistentDataPath, ResourceLabel.PlayerConfigXml);
  57. }
  58. return configPath;
  59. }
  60. }
  61. public static string configPath;
  62. #endregion
  63. private static string UnvalidConfigMD5 = "";
  64. private static void LoadConfigDocument()
  65. {
  66. //if (!PlayerPrefManager.GetBool(PlayerPrefManager.INTERACT_CONFIG, false))
  67. //{
  68. // Debug.LogWarning("Download Archive : did not interact");
  69. // PlayerDocumentDamageFlag = true;
  70. // SerialNumberRequestFlag = false;
  71. // return;
  72. //}
  73. int defaultVersion;
  74. int nativeVersion;
  75. XmlNode node;
  76. XmlDocument nativeDoc = new XmlDocument();
  77. if (File.Exists(ConfigPath))
  78. {
  79. try
  80. {
  81. StreamReader sr = new StreamReader(ConfigPath);
  82. nativeDoc.LoadXml(sr.ReadToEnd());
  83. sr.Close();
  84. Auxiliary.DecryptXml(nativeDoc);
  85. }
  86. catch (Exception)
  87. {
  88. Debug.LogWarning("Download Archive : MD5 doesn't match");
  89. //ManaDebug.Log("Download Archive");
  90. PlayerDocumentDamageFlag = true;
  91. SerialNumberRequestFlag = false;
  92. return;
  93. }
  94. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlayerConfig, Folder.Default);
  95. DefaultConfigDocument.LoadXml(textAsset.text);
  96. defaultVersion = int.Parse(DefaultConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value);
  97. node = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version);
  98. if (node == null)
  99. {
  100. StreamWriter sw = new StreamWriter(ConfigPath);
  101. sw.Write(DefaultConfigDocument.OuterXml);
  102. sw.Close();
  103. configDocument = DefaultConfigDocument;
  104. }
  105. else
  106. {
  107. nativeVersion = int.Parse(node.Attributes[0].Value);
  108. if (nativeVersion == ConfigReplayVersion)
  109. {
  110. configDocument = DefaultConfigDocument;
  111. int currentReplayVersion = int.Parse(nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ReplayVersion).Attributes[0].Value);
  112. SaveIntToConfig(PlayerConfigLabel.ReplayVersion, currentReplayVersion + 1);
  113. //Debug.Log(currentReplayVersion);
  114. }
  115. else if (nativeVersion < defaultVersion)
  116. {
  117. byte[] bytes;
  118. MD5 md5 = new MD5CryptoServiceProvider();
  119. if (nativeVersion <= 4)
  120. {
  121. bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
  122. }
  123. else
  124. {
  125. bytes = File.ReadAllBytes(ConfigPath);
  126. }
  127. if (PlayerPrefs.GetString(Lib.ConfigPrefs) != UnvalidConfigMD5 && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
  128. {
  129. Debug.LogWarning("Download Archive : MD5 doesn't match");
  130. //ManaDebug.Log("Download Archive");
  131. PlayerDocumentDamageFlag = true;
  132. SerialNumberRequestFlag = false;
  133. return;
  134. }
  135. else
  136. {
  137. configDocument = UpdateConfigDocument(nativeVersion, nativeDoc, DefaultConfigDocument);
  138. //HttpManager.UploadConfig();
  139. }
  140. }
  141. else if (nativeVersion > defaultVersion)
  142. {
  143. configDocument = DefaultConfigDocument;
  144. }
  145. else
  146. {
  147. byte[] bytes = File.ReadAllBytes(ConfigPath);
  148. MD5 md5 = new MD5CryptoServiceProvider();
  149. if (PlayerPrefs.GetString(Lib.ConfigPrefs) != UnvalidConfigMD5 && PlayerPrefs.GetString(Lib.ConfigPrefs) != Auxiliary.ToString(md5.ComputeHash(bytes)))
  150. {
  151. Debug.LogWarning("Download Archive : MD5 doesn't match");
  152. //ManaDebug.Log("Download Archive");
  153. PlayerDocumentDamageFlag = true;
  154. SerialNumberRequestFlag = false;
  155. return;
  156. }
  157. configDocument = nativeDoc;
  158. }
  159. }
  160. }
  161. else
  162. {
  163. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlayerConfig, Folder.Default);
  164. DefaultConfigDocument.LoadXml(textAsset.text);
  165. Debug.LogWarning("Download Archive");
  166. //ManaDebug.Log("Download Archive");
  167. PlayerDocumentDamageFlag = true;
  168. SerialNumberRequestFlag = false;
  169. return;
  170. }
  171. }
  172. private float MaxUrlWaitTime = 10;
  173. public void Update()
  174. {
  175. if (PlayerDocumentDamageFlag)
  176. {
  177. UrlTimer += Time.deltaTime;
  178. if (UrlTimer >= MaxUrlWaitTime)
  179. {
  180. PlayerDocumentDamageFlag = false;
  181. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlayerConfig, Folder.Default);
  182. configDocument = new XmlDocument();
  183. configDocument.LoadXml(textAsset.text);
  184. return;
  185. }
  186. }
  187. if (!SerialNumberRequestFlag)
  188. {
  189. if (HttpManager.SerialNumber != PlayerConfigLabel.DefaultSerialNumber)
  190. {
  191. SerialNumberRequestFlag = true;
  192. HttpManager.GetConfigBySerialNumber(HttpManager.SerialNumber, RecoveConfigDocument);
  193. }
  194. }
  195. }
  196. public override bool InitAtOnce()
  197. {
  198. if (base.InitAtOnce())
  199. {
  200. return true;
  201. }
  202. enabled = true;
  203. return false;
  204. }
  205. public static void RecoveConfigDocument(JsonData jsonData)
  206. {
  207. if (!PlayerDocumentDamageFlag)
  208. {
  209. return;
  210. }
  211. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlayerConfig, Folder.Default);
  212. DefaultConfigDocument.LoadXml(textAsset.text);
  213. //Debug.Log(jsonData.ToJson());
  214. if (jsonData.Inst_Object.Keys.Contains("l"))
  215. {
  216. XmlDocument recoverdDocument = new XmlDocument();
  217. recoverdDocument.LoadXml(jsonData["l"].ToString());
  218. int RecoverdVersion = int.Parse(recoverdDocument.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value);
  219. int DefaultVersion = int.Parse(DefaultConfigDocument.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value);
  220. PlayerDocumentDamageFlag = false;
  221. if (RecoverdVersion <= DefaultVersion)
  222. {
  223. UpdateConfigDocument(RecoverdVersion, recoverdDocument, DefaultConfigDocument);
  224. configDocument = recoverdDocument;
  225. PlayerPrefManager.SaveBool(PlayerPrefManager.INTERACT_CONFIG, true);
  226. }
  227. else if (RecoverdVersion > DefaultVersion)
  228. {
  229. configDocument = DefaultConfigDocument;
  230. }
  231. }
  232. else
  233. {
  234. if (!IDRequestFlag)
  235. {
  236. if (HttpManager.ID != PlayerConfigLabel.DefaultID)
  237. {
  238. IDRequestFlag = true;
  239. Debug.LogWarning("DownloadByID");
  240. HttpManager.GetConfigByID(HttpManager.ID, RecoveConfigDocument);
  241. }
  242. else
  243. {
  244. Debug.LogWarning("Use Default");
  245. configDocument = DefaultConfigDocument;
  246. PlayerDocumentDamageFlag = false;
  247. }
  248. }
  249. else
  250. {
  251. Debug.LogWarning("Use Default");
  252. configDocument = DefaultConfigDocument;
  253. PlayerDocumentDamageFlag = false;
  254. }
  255. }
  256. }
  257. public static void SaveSkillList()
  258. {
  259. if (TutorialManager.NewplayerTutorial || !Manager.Inited)
  260. {
  261. return;
  262. }
  263. XmlNode xmlNode;
  264. XmlAttribute xmlAttribute;
  265. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList);
  266. xmlNode.RemoveAll();
  267. for (int i = 0; i < Manager.SkillList.Count; i++)
  268. {
  269. if (Manager.SkillList[i].SkillType == SkillType.Skill)
  270. {
  271. #region Skill
  272. Skill skill = (Skill)Manager.SkillList[i];
  273. xmlNode = xmlNode.AppendChild(ConfigDocument.CreateNode(XmlNodeType.Element, PlayerConfigLabel.Skill, ""));
  274. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ID));
  275. xmlAttribute.Value = skill.FullID;
  276. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.SkillType));
  277. xmlAttribute.Value = skill.SkillType.ToString();
  278. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ItemStatus));
  279. xmlAttribute.Value = skill.ItemStatus.ToString();
  280. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.Level));
  281. xmlAttribute.Value = skill.Level.ToString();
  282. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.CoolTimer));
  283. xmlAttribute.Value = skill.CoolTimer.ToString("0");
  284. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.UseTimer));
  285. xmlAttribute.Value = skill.UseTimer.ToString("0");
  286. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList);
  287. #endregion
  288. }
  289. else if (Manager.SkillList[i].SkillType == SkillType.Pack)
  290. {
  291. #region Pack
  292. Pack pack = (Pack)Manager.SkillList[i];
  293. xmlNode = xmlNode.AppendChild(ConfigDocument.CreateNode(XmlNodeType.Element, PlayerConfigLabel.Skill, ""));
  294. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ID));
  295. xmlAttribute.Value = pack.FullID;
  296. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.SkillType));
  297. xmlAttribute.Value = pack.SkillType.ToString();
  298. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ItemStatus));
  299. xmlAttribute.Value = pack.ItemStatus.ToString();
  300. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.Level));
  301. xmlAttribute.Value = pack.Level.ToString();
  302. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList);
  303. #endregion
  304. }
  305. else if (Manager.SkillList[i].SkillType == SkillType.Ability)
  306. {
  307. #region Ability
  308. Ability ability = (Ability)Manager.SkillList[i];
  309. xmlNode = xmlNode.AppendChild(ConfigDocument.CreateNode(XmlNodeType.Element, PlayerConfigLabel.Skill, ""));
  310. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ID));
  311. xmlAttribute.Value = ability.FullID;
  312. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.SkillType));
  313. xmlAttribute.Value = ability.SkillType.ToString();
  314. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ItemStatus));
  315. xmlAttribute.Value = ability.ItemStatus.ToString();
  316. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.Level));
  317. xmlAttribute.Value = ability.Level.ToString();
  318. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList);
  319. #endregion
  320. }
  321. else if (Manager.SkillList[i].SkillType == SkillType.BigSkill)
  322. {
  323. #region BigSkill
  324. BigSkill bigSkill = (BigSkill)Manager.SkillList[i];
  325. xmlNode = xmlNode.AppendChild(ConfigDocument.CreateNode(XmlNodeType.Element, PlayerConfigLabel.Skill, ""));
  326. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ID));
  327. xmlAttribute.Value = bigSkill.FullID;
  328. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.SkillType));
  329. xmlAttribute.Value = bigSkill.SkillType.ToString();
  330. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.ItemStatus));
  331. xmlAttribute.Value = bigSkill.ItemStatus.ToString();
  332. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.BarStatus));
  333. xmlAttribute.Value = bigSkill.BarStatus.ToString();
  334. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.Level));
  335. xmlAttribute.Value = bigSkill.Level.ToString();
  336. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.CoolTimer));
  337. xmlAttribute.Value = bigSkill.CoolTimer.ToString("0");
  338. xmlAttribute = xmlNode.Attributes.Append(ConfigDocument.CreateAttribute(PlayerConfigLabel.UseTimer));
  339. xmlAttribute.Value = bigSkill.UseTimer.ToString("0");
  340. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList);
  341. #endregion
  342. }
  343. }
  344. }
  345. public static void SaveDress()
  346. {
  347. XmlNode xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressList);
  348. xmlNode.Attributes[0].Value = "";
  349. for (int i = 0; i < PlayerManager.BoughtCloseIDs.Count; i++)
  350. {
  351. xmlNode.Attributes[0].Value += PlayerManager.BoughtCloseIDs[i] + " ";
  352. }
  353. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  354. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressData);
  355. for (int i = 0; i < PlayerManager.DressDatas.Count; i++)
  356. {
  357. xmlNode.Attributes[i].Value = PlayerManager.DressDatas[i];
  358. }
  359. }
  360. public static void SaveAchieve()
  361. {
  362. XmlNode xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveList);
  363. xmlNode.Attributes[0].Value = "";
  364. foreach (var kv in AchieveManager.AchieveItemDictionary)
  365. {
  366. if (!kv.Value.Lock)
  367. {
  368. xmlNode.Attributes[0].Value += kv.Value.ID + " ";
  369. }
  370. }
  371. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  372. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[0].Value = Manager.PlayADsAmt.ToString("0");
  373. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[1].Value = Manager.UseSkillAmt.ToString("0");
  374. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[2].Value = Manager.SignAmt.ToString("0");
  375. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[3].Value = Manager.ShareAmt.ToString("0");
  376. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[4].Value = Manager.AllElfLevel.ToString("0");
  377. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[5].Value = Manager.PlayMinigameAmt.ToString("0");
  378. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[6].Value = Manager.TotalFlowerAwardCoin.ToString("0");
  379. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[7].Value = Manager.TotalVisitPerson.ToString("0");
  380. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[8].Value = Manager.TotalSpendDiamond.ToString("0");
  381. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[9].Value = Manager.CreateRoomAmt.ToString("0");
  382. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[10].Value = Manager.CreateChestAmt.ToString("0");
  383. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[11].Value = Manager.CreateLuckyChestAmt.ToString("0");
  384. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[12].Value = Manager.CreateGuessColorChestAmt.ToString("0");
  385. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[13].Value = Manager.CreateGuessNumberChestAmt.ToString("0");
  386. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[14].Value = Manager.GetChestAwardAmt.ToString("0");
  387. }
  388. public static void SavePlantList()
  389. {
  390. if (VisitManager.InVisit || TutorialManager.NewplayerTutorial)
  391. {
  392. return;
  393. }
  394. XmlAttributeCollection attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.PlantList).Attributes;
  395. attribute[0].Value = "";
  396. for (int i = 0; i < GardenManager.PlantSlotList.Count; i++)
  397. {
  398. Slot slot = GardenManager.PlantSlotList[i];
  399. attribute[0].Value += slot.ID + "," + slot.Index + " ";
  400. }
  401. attribute[0].Value = attribute[0].Value.TrimEnd(' ');
  402. }
  403. public static void SaveDatas()
  404. {
  405. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.Coin).Attributes[0].Value = Manager.Coin.ToString("0");
  406. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.Diamond).Attributes[0].Value = Manager.Diamond.ToString("0");
  407. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SignTime).Attributes[0].Value = SignManager.LastSignTime.ToString();
  408. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SignIndex).Attributes[0].Value = SignManager.SignIndex.ToString();
  409. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SignRound).Attributes[0].Value = SignManager.SignRound.ToString();
  410. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.QuitFlag).Attributes[0].Value = HttpManager.IsConnect.ToInt().ToString();
  411. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.QuitTime).Attributes[0].Value = HttpManager.CurrentDateTime.ToString();
  412. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.MiniTimer).Attributes[0].Value = Manager.MinigameCDTimer.ToString("0");
  413. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.CircleTimer).Attributes[0].Value = Manager.IncomeCircleTimer.ToString("0");
  414. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.ID).Attributes[0].Value = HttpManager.ID;
  415. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SerialNumber).Attributes[0].Value = HttpManager.SerialNumber;
  416. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.Language).Attributes[0].Value = LanguageManager.CurrentLanguage.ToString();
  417. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.MiniGameIndex).Attributes[0].Value = MiniGameManager.MiniGameIndex.ToString();
  418. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.NewplayerTutorial).Attributes[0].Value = TutorialManager.NewplayerTutorial.ToInt().ToString();
  419. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.MemoryMinigameTutorial).Attributes[0].Value = TutorialManager.memoryMinigameTutorial.ToInt().ToString();
  420. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.VisitTutorial).Attributes[0].Value = TutorialManager.visitTutorial.ToInt().ToString();
  421. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressroomTutorial).Attributes[0].Value = TutorialManager.dressroomTutorial.ToInt().ToString();
  422. if (TutorialManager.findSoloMinigameTutorial || TutorialManager.FindSoloMinigameTutorial)
  423. {
  424. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorial).Attributes[0].Value = "1";
  425. }
  426. else
  427. {
  428. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorial).Attributes[0].Value = "0";
  429. }
  430. if (TutorialManager.findMissingMinigameTutorial || TutorialManager.FindMissingMinigameTutorial)
  431. {
  432. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial).Attributes[0].Value = "1";
  433. }
  434. else
  435. {
  436. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial).Attributes[0].Value = "0";
  437. }
  438. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.TutorialPlazaRoom).Attributes[0].Value = TutorialManager.plazaRoomTutorial.ToInt().ToString();
  439. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.NewplayerTutorialIndex).Attributes[0].Value = TutorialManager.NewplayerTutorialIndex.ToString();
  440. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.MemoryMinigameTutorialIndex).Attributes[0].Value = TutorialManager.MemoryMinigameTutorialIndex.ToString();
  441. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.VisitTutorialIndex).Attributes[0].Value = TutorialManager.VisitTutorialIndex.ToString();
  442. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressroomIndex).Attributes[0].Value = TutorialManager.DressroomTutorialIndex.ToString();
  443. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorialIndex).Attributes[0].Value = TutorialManager.FindSoloMinigameTutorialIndex.ToString();
  444. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorialIndex).Attributes[0].Value = TutorialManager.FindMissingMinigameTutorialIndex.ToString();
  445. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.TutorialIndexPlazaRoom).Attributes[0].Value = TutorialManager.PlazaRoomTutorialIndex.ToString();
  446. }
  447. public static void SaveFlowers()
  448. {
  449. XmlAttribute attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerList).Attributes[0];
  450. XmlAttribute attribute1 = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerAmtList).Attributes[0];
  451. attribute.Value = "";
  452. attribute1.Value = "";
  453. foreach (var kv in GardenManager.FlowerInfoDictionary)
  454. {
  455. if (kv.Value.Unlock)
  456. {
  457. attribute.Value += kv.Value.ID + " ";
  458. attribute1.Value += kv.Value.Amount + " ";
  459. }
  460. }
  461. attribute.Value = attribute.Value.Trim(' ');
  462. attribute1.Value = attribute1.Value.Trim(' ');
  463. }
  464. public static void SaveConfigDocument()
  465. {
  466. if (Initializer.Inited)
  467. {
  468. SaveSkillList();
  469. SaveAchieve();
  470. SaveDress();
  471. SavePlantList();
  472. SaveDatas();
  473. SaveFlowers();
  474. ChestManager.SaveToConfig();
  475. }
  476. }
  477. public static void SaveConfigDocumentToDisk()
  478. {
  479. if (Initializer.Inited)
  480. {
  481. XmlDocument doc = new XmlDocument();
  482. doc.LoadXml(ConfigDocument.OuterXml);
  483. Auxiliary.EncryptXml(doc);
  484. StreamWriter sw = new StreamWriter(ConfigPath);
  485. sw.Write(doc.OuterXml);
  486. sw.Close();
  487. byte[] bytes = File.ReadAllBytes(ConfigPath);
  488. //byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
  489. MD5 md5 = new MD5CryptoServiceProvider();
  490. PlayerPrefs.SetString(Lib.ConfigPrefs, Auxiliary.ToString(md5.ComputeHash(bytes)));
  491. }
  492. }
  493. public static void ResetConfigDocument()
  494. {
  495. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = ConfigReplayVersion.ToString();
  496. SaveConfigDocument();
  497. Manager.UploadConfigFlag = true;
  498. Manager.DownloadConfigFlag = true;
  499. SaveConfigDocumentToDisk();
  500. DelayCall.Call
  501. (
  502. 1,
  503. () =>
  504. {
  505. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
  506. }
  507. );
  508. }
  509. public static int GetIntFormConfig(string node)
  510. {
  511. return int.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  512. }
  513. public static bool GetBoolFormConfig(string node)
  514. {
  515. return int.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
  516. }
  517. public static float GetFloatFormConfig(string node)
  518. {
  519. return float.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  520. }
  521. public static string GetStringFormConfig(string node)
  522. {
  523. return ConfigRootNode.SelectSingleNode(node).Attributes[0].Value;
  524. }
  525. public static double GetDoubleFormConfig(string node)
  526. {
  527. return double.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  528. }
  529. public static void SaveIntToConfig(string node, int value)
  530. {
  531. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  532. }
  533. public static void SaveBoolToConfig(string node, bool value)
  534. {
  535. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
  536. }
  537. public static void SaveFloatToConfig(string node, float value)
  538. {
  539. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  540. }
  541. public static void SaveStringToConfig(string node, string value)
  542. {
  543. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value;
  544. }
  545. public static void SaveDoubleToConfig(string node, double value)
  546. {
  547. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  548. }
  549. public static List<int> GetIntList(char splitChar, string nodeName, List<int> defaultList)
  550. {
  551. return Auxiliary.StringToInts(splitChar, ConfigRootNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  552. }
  553. public static List<string> GetStringList(char splitChar, string nodeName, List<string> defaultList)
  554. {
  555. return Auxiliary.StringToStrings(splitChar, ConfigRootNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  556. }
  557. public static List<int> GetDressList()
  558. {
  559. List<int> list = new List<int>();
  560. XmlAttributeCollection attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressList).Attributes;
  561. return Auxiliary.StringToInts(' ', attribute[0].Value, list);
  562. }
  563. public static List<int> GetDressDataIDs(Player player)
  564. {
  565. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  566. //{
  567. // Debug.LogWarning(VARIABLE.Key);
  568. //}
  569. List<int> dressDataIDs = new List<int>();
  570. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Head]);
  571. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Dress]);
  572. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Shoe]);
  573. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.HeadWear]);
  574. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Top]);
  575. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Eye]);
  576. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Mouse]);
  577. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Wing]);
  578. return dressDataIDs;
  579. }
  580. public static List<int> GetDressDataIDs(List<string> dressdataNames)
  581. {
  582. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  583. //{
  584. // Debug.LogWarning(VARIABLE.Key);
  585. //}
  586. List<int> dressDataIDs = new List<int>();
  587. int index = 0;
  588. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  589. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  590. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  591. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  592. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  593. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  594. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  595. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  596. return dressDataIDs;
  597. }
  598. public static List<int> GetDressDataIDs(ISFSObject parameter)
  599. {
  600. List<int> ids = parameter.GetIntArray(InfoLabel.Close.GetHashString()).ToList();
  601. return ids;
  602. }
  603. public static List<string> GetDressData(SFSObject parameter)
  604. {
  605. List<int> ids = GetDressDataIDs(parameter);
  606. List<string> dressData = new List<string>();
  607. foreach (var id in ids)
  608. {
  609. dressData.Add(PlayerManager.CloseItemDictionary[id].ArmatureName);
  610. }
  611. return dressData;
  612. }
  613. public static List<string> GetDressData(XmlNode node = null)
  614. {
  615. XmlNode xmlNode;
  616. if (node == null)
  617. {
  618. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressData);
  619. }
  620. else
  621. {
  622. xmlNode = node.SelectSingleNode(PlayerConfigLabel.DressData);
  623. }
  624. List<string> dataList = new List<string>();
  625. if (xmlNode != null && xmlNode.Attributes.Count == 12)
  626. {
  627. dataList.Add(xmlNode.Attributes[0].Value);
  628. dataList.Add(xmlNode.Attributes[1].Value);
  629. dataList.Add(xmlNode.Attributes[2].Value);
  630. dataList.Add(xmlNode.Attributes[3].Value);
  631. dataList.Add(xmlNode.Attributes[4].Value);
  632. dataList.Add(xmlNode.Attributes[5].Value);
  633. dataList.Add(xmlNode.Attributes[6].Value);
  634. dataList.Add(xmlNode.Attributes[7].Value);
  635. dataList.Add(xmlNode.Attributes[8].Value);
  636. dataList.Add(xmlNode.Attributes[9].Value);
  637. dataList.Add(xmlNode.Attributes[10].Value);
  638. dataList.Add(xmlNode.Attributes[11].Value);
  639. //dataList[8] = "长袖9左";
  640. //dataList[9] = "Empty";
  641. //dataList[10] = "长袖9右";
  642. //dataList[11] = "Empty";
  643. }
  644. else if(xmlNode != null && xmlNode.Attributes.Count == 8)
  645. {
  646. dataList.Add(xmlNode.Attributes[0].Value);
  647. dataList.Add(xmlNode.Attributes[1].Value);
  648. dataList.Add(xmlNode.Attributes[2].Value);
  649. dataList.Add(xmlNode.Attributes[3].Value);
  650. dataList.Add(xmlNode.Attributes[4].Value);
  651. dataList.Add(xmlNode.Attributes[5].Value);
  652. dataList.Add(xmlNode.Attributes[6].Value);
  653. dataList.Add(xmlNode.Attributes[7].Value);
  654. dataList.AddRange (GetSleeveListByTop(xmlNode.Attributes[4].Value));
  655. }
  656. else
  657. {
  658. float rate = Random.Range(0f, 1f);
  659. if (rate < 0.33f)
  660. {
  661. dataList.Add("脑壳1");
  662. dataList.Add("裙子1");
  663. dataList.Add("鞋子1");
  664. dataList.Add("头饰品1");
  665. dataList.Add("上衣1");
  666. dataList.Add("眼睛1");
  667. dataList.Add("嘴巴1");
  668. dataList.Add("Empty");
  669. dataList.Add("Empty");
  670. dataList.Add("短袖1左");
  671. dataList.Add("Empty");
  672. dataList.Add("短袖1右");
  673. }
  674. else if (rate < 0.66f)
  675. {
  676. dataList.Add("脑壳2");
  677. dataList.Add("裙子2");
  678. dataList.Add("鞋子2");
  679. dataList.Add("头饰品2");
  680. dataList.Add("上衣2");
  681. dataList.Add("眼睛2");
  682. dataList.Add("嘴巴2");
  683. dataList.Add("Empty");
  684. dataList.Add("Empty");
  685. dataList.Add("短袖2左");
  686. dataList.Add("Empty");
  687. dataList.Add("短袖2右");
  688. }
  689. else
  690. {
  691. dataList.Add("脑壳3");
  692. dataList.Add("裙子3");
  693. dataList.Add("鞋子3");
  694. dataList.Add("头饰品3");
  695. dataList.Add("上衣3");
  696. dataList.Add("眼睛3");
  697. dataList.Add("嘴巴3");
  698. dataList.Add("Empty");
  699. dataList.Add("Empty");
  700. dataList.Add("短袖2左");
  701. dataList.Add("Empty");
  702. dataList.Add("短袖2右");
  703. }
  704. }
  705. return dataList;
  706. }
  707. public static List<int> GetFlowerList()
  708. {
  709. List<int> list = new List<int>();
  710. XmlAttributeCollection attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerList).Attributes;
  711. return Auxiliary.StringToInts(' ', attribute[0].Value, list);
  712. }
  713. public static List<int> GetLockAchieveIDs()
  714. {
  715. return Auxiliary.StringToInts(' ', GetStringFormConfig(PlayerConfigLabel.AchieveList), new List<int>());
  716. }
  717. public static List<double> GetAchieveValues()
  718. {
  719. List<double> dataList = new List<double>();
  720. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[0].Value));
  721. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[1].Value));
  722. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[2].Value));
  723. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[3].Value));
  724. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[4].Value));
  725. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[5].Value));
  726. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[6].Value));
  727. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[7].Value));
  728. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[8].Value));
  729. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[9].Value));
  730. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[10].Value));
  731. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[11].Value));
  732. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[12].Value));
  733. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[13].Value));
  734. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[14].Value));
  735. return dataList;
  736. }
  737. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  738. {
  739. List<KV<int, int>> list = new List<KV<int, int>>();
  740. XmlNode xmlNode;
  741. if (node == null)
  742. {
  743. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.PlantList);
  744. }
  745. else
  746. {
  747. xmlNode = node.SelectSingleNode(PlayerConfigLabel.PlantList);
  748. }
  749. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  750. {
  751. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  752. for (int i = 0; i < strings.Length; i++)
  753. {
  754. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  755. }
  756. }
  757. return list;
  758. }
  759. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  760. {
  761. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  762. XmlNodeList xmlNodeList;
  763. if (node == null)
  764. {
  765. xmlNodeList = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
  766. }
  767. else
  768. {
  769. xmlNodeList = node.SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
  770. }
  771. for (int i = 0; i < xmlNodeList.Count; i++)
  772. {
  773. attributeList.Add(xmlNodeList[i].Attributes);
  774. }
  775. return attributeList;
  776. }
  777. public static List<string> GetOfflineConfig()
  778. {
  779. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.OfflineConfig, Folder.Config);
  780. XmlDocument xmlDoc = new XmlDocument();
  781. xmlDoc.LoadXml(textAsset.text);
  782. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  783. List<string> strList = new List<string>()
  784. {
  785. xmlNode.Attributes[1].Value,
  786. xmlNode.Attributes[2].Value,
  787. xmlNode.Attributes[3].Value,
  788. };
  789. return strList;
  790. }
  791. public static XmlAttributeCollection GetVisitConfig()
  792. {
  793. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.VisitConfig, Folder.Config);
  794. XmlDocument xmlDoc = new XmlDocument();
  795. xmlDoc.LoadXml(textAsset.text);
  796. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  797. return xmlNode.Attributes;
  798. }
  799. public static XmlAttributeCollection GetPlazaRoomConfig()
  800. {
  801. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlazaroomConfig, Folder.Config);
  802. XmlDocument xmlDoc = new XmlDocument();
  803. xmlDoc.LoadXml(textAsset.text);
  804. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  805. return xmlNode.Attributes;
  806. }
  807. public static XmlAttributeCollection GetAwardConfig()
  808. {
  809. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AwardConfig, Folder.Config);
  810. XmlDocument xmlDoc = new XmlDocument();
  811. xmlDoc.LoadXml(textAsset.text);
  812. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  813. return xmlNode.Attributes;
  814. }
  815. public static List<XmlAttributeCollection> GetIAPConfig()
  816. {
  817. TextAsset textAsset;
  818. XmlNodeList xmlNodeList;
  819. XmlDocument xmlDoc = new XmlDocument();
  820. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  821. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.IAPConfig, Folder.Config);
  822. xmlDoc.LoadXml(textAsset.text);
  823. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  824. for (int i = 0; i < xmlNodeList.Count; i++)
  825. {
  826. attributeList.Add(xmlNodeList[i].Attributes);
  827. }
  828. return attributeList;
  829. }
  830. public static List<XmlAttributeCollection> GetSkillConfig()
  831. {
  832. TextAsset textAsset;
  833. XmlDocument xmlDoc = new XmlDocument();
  834. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  835. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  836. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PackConfig, Folder.Config);
  837. xmlDoc.LoadXml(textAsset.text);
  838. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  839. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.SkillConfig, Folder.Config);
  840. xmlDoc.LoadXml(textAsset.text);
  841. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  842. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AbilityConfig, Folder.Config);
  843. xmlDoc.LoadXml(textAsset.text);
  844. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  845. for (int i = 0; i < xmlNodeList.Count; i++)
  846. {
  847. for (int j = 0; j < xmlNodeList[i].Count; j++)
  848. {
  849. attributeList.Add(xmlNodeList[i][j].Attributes);
  850. }
  851. }
  852. return attributeList;
  853. }
  854. public static List<XmlAttributeCollection> GetSignConfig()
  855. {
  856. TextAsset textAsset;
  857. XmlNodeList xmlNodeList;
  858. XmlDocument xmlDoc = new XmlDocument();
  859. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  860. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.SigninConfig, Folder.Config);
  861. xmlDoc.LoadXml(textAsset.text);
  862. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  863. for (int i = 0; i < xmlNodeList.Count; i++)
  864. {
  865. attributeList.Add(xmlNodeList[i].Attributes);
  866. }
  867. return attributeList;
  868. }
  869. public static List<XmlAttributeCollection> GetFlowerConfig(TextAsset textAsset = null)
  870. {
  871. XmlNodeList xmlNodeList;
  872. XmlDocument xmlDoc = new XmlDocument();
  873. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  874. if (textAsset == null)
  875. {
  876. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.FlowerConfig, Folder.Config);
  877. }
  878. xmlDoc.LoadXml(textAsset.text);
  879. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  880. for (int i = 0; i < xmlNodeList.Count; i++)
  881. {
  882. attributeList.Add(xmlNodeList[i].Attributes);
  883. }
  884. return attributeList;
  885. }
  886. public static List<XmlAttributeCollection> GetLotteryConfig()
  887. {
  888. TextAsset textAsset;
  889. XmlNodeList xmlNodeList;
  890. XmlDocument xmlDoc = new XmlDocument();
  891. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  892. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.LotteryConfig, Folder.Config);
  893. xmlDoc.LoadXml(textAsset.text);
  894. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  895. for (int i = 0; i < xmlNodeList.Count; i++)
  896. {
  897. attributeList.Add(xmlNodeList[i].Attributes);
  898. }
  899. return attributeList;
  900. }
  901. public static List<XmlAttributeCollection> GetAchieveConfig()
  902. {
  903. TextAsset textAsset;
  904. XmlNodeList xmlNodeList;
  905. XmlDocument xmlDoc = new XmlDocument();
  906. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  907. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AchieveConfig, Folder.Config);
  908. xmlDoc.LoadXml(textAsset.text);
  909. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  910. for (int i = 0; i < xmlNodeList.Count; i++)
  911. {
  912. attributeList.Add(xmlNodeList[i].Attributes);
  913. }
  914. return attributeList;
  915. }
  916. public static List<XmlAttributeCollection> GetDressRoomConfig(TextAsset textAsset = null)
  917. {
  918. XmlNodeList xmlNodeList;
  919. XmlDocument xmlDoc = new XmlDocument();
  920. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  921. if (textAsset == null)
  922. {
  923. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.DressroomConfig, Folder.Config);
  924. }
  925. xmlDoc.LoadXml(textAsset.text);
  926. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  927. for (int i = 0; i < xmlNodeList.Count; i++)
  928. {
  929. attributeList.Add(xmlNodeList[i].Attributes);
  930. }
  931. return attributeList;
  932. }
  933. public static int GetGardenLevel(XmlDocument xmlDocument)
  934. {
  935. XmlNodeList nodeList = xmlDocument.SelectNodes(PlayerConfigLabel.RootNode + "/" + PlayerConfigLabel.SkillList + "/" + PlayerConfigLabel.Skill);
  936. for (int i = 0; i < nodeList.Count; i++)
  937. {
  938. if (nodeList[i].Attributes[0].Value == "Ability1")
  939. {
  940. return int.Parse(nodeList[i].Attributes[3].Value);
  941. }
  942. }
  943. return -1;
  944. }
  945. public static int GetConfigVersion(XmlDocument xmlDocument)
  946. {
  947. return int.Parse(xmlDocument.SelectSingleNode(PlayerConfigLabel.RootNode + "/" + PlayerConfigLabel.Version).Attributes[0].Value);
  948. }
  949. public static List<string> GetDefaultDressDatas()
  950. {
  951. List<string> defaultDressDatas = new List<string>();
  952. defaultDressDatas.Add("脑壳1");
  953. defaultDressDatas.Add("裙子1");
  954. defaultDressDatas.Add("鞋子1");
  955. defaultDressDatas.Add("头饰品1");
  956. defaultDressDatas.Add("上衣1");
  957. defaultDressDatas.Add("眼睛1");
  958. defaultDressDatas.Add("嘴巴1");
  959. defaultDressDatas.Add("Empty");
  960. defaultDressDatas.Add("Empty");
  961. defaultDressDatas.Add("短袖2左");
  962. defaultDressDatas.Add("Empty");
  963. defaultDressDatas.Add("短袖2右");
  964. return defaultDressDatas;
  965. }
  966. public static XmlDocument GetXmlDocument(string ConfigName)
  967. {
  968. TextAsset textAsset = ResourceManager.Load<TextAsset>(ConfigName, Folder.Config);
  969. XmlDocument xmlDocument = new XmlDocument();
  970. xmlDocument.LoadXml(textAsset.text);
  971. return xmlDocument;
  972. }
  973. //玩家存档版本大于默认存档版本时需要清空
  974. //玩家存档版本小于默认存档版本时需要更新
  975. //玩家存档版本等于ReplayVersion时需要标记为重玩
  976. public static XmlDocument UpdateConfigDocument(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  977. {
  978. if (nativeVersion < 0)
  979. {
  980. Debug.LogWarning("UpdateArchive to 0");
  981. ToVersion0(nativeDoc, defaultDoc);
  982. }
  983. if (nativeVersion < 1)
  984. {
  985. Debug.LogWarning("UpdateArchive to 1");
  986. ToVersion1(nativeDoc, defaultDoc);
  987. }
  988. if (nativeVersion < 2)
  989. {
  990. Debug.LogWarning("UpdateArchive to 2");
  991. ToVersion2(nativeDoc, defaultDoc);
  992. }
  993. if (nativeVersion < 3)
  994. {
  995. Debug.LogWarning("UpdateArchive to 3");
  996. ToVersion3(nativeDoc, defaultDoc);
  997. }
  998. if (nativeVersion < 4)
  999. {
  1000. Debug.LogWarning("UpdateArchive to 4");
  1001. ToVersion4(nativeDoc, defaultDoc);
  1002. }
  1003. if (nativeVersion < 5)
  1004. {
  1005. Debug.LogWarning("UpdateArchive to 5");
  1006. ToVersion5(nativeDoc, defaultDoc);
  1007. }
  1008. if (nativeVersion < 6)
  1009. {
  1010. Debug.LogWarning("UpdateArchive to 6");
  1011. ToVersion6(nativeDoc, defaultDoc);
  1012. }
  1013. if (nativeVersion < 7)
  1014. {
  1015. Debug.LogWarning("UpdateArchive to 7");
  1016. ToVersion7(nativeDoc, defaultDoc);
  1017. }
  1018. if (nativeVersion < 8)
  1019. {
  1020. Debug.LogWarning("UpdateArchive to 8");
  1021. ToVersion8(nativeDoc, defaultDoc);
  1022. }
  1023. if (nativeVersion < 9)
  1024. {
  1025. Debug.LogWarning("UpdateArchive to 9");
  1026. ToVersion9(nativeDoc, defaultDoc);
  1027. }
  1028. if (nativeVersion < 10)
  1029. {
  1030. Debug.LogWarning("UpdateArchive to 10");
  1031. ToVersion10(nativeDoc, defaultDoc);
  1032. }
  1033. if (nativeVersion < 11)
  1034. {
  1035. Debug.LogWarning("UpdateArchive to 11");
  1036. ToVersion11(nativeDoc, defaultDoc);
  1037. }
  1038. if (nativeVersion < 12)
  1039. {
  1040. Debug.LogWarning("UpdateArchive to 12");
  1041. ToVersion12(nativeDoc, defaultDoc);
  1042. }
  1043. if (nativeVersion < 13)
  1044. {
  1045. Debug.LogWarning("UpdateArchive to 13");
  1046. ToVersion13(nativeDoc, defaultDoc);
  1047. }
  1048. if (nativeVersion < 14)
  1049. {
  1050. Debug.LogWarning("UpdateArchive to 14");
  1051. ToVersion14(nativeDoc, defaultDoc);
  1052. }
  1053. if (nativeVersion < 15)
  1054. {
  1055. Debug.LogWarning("UpdateArchive to 15");
  1056. ToVersion15(nativeDoc, defaultDoc);
  1057. }
  1058. if (nativeVersion < 16)
  1059. {
  1060. Debug.LogWarning("UpdateArchive to 16");
  1061. ToVersion16(nativeDoc, defaultDoc);
  1062. }
  1063. if (nativeVersion < 17)
  1064. {
  1065. Debug.LogWarning("UpdateArchive to 17");
  1066. ToVersion17(nativeDoc, defaultDoc);
  1067. }
  1068. if (nativeVersion < 18)
  1069. {
  1070. Debug.LogWarning("UpdateArchive to 18");
  1071. ToVersion18(nativeDoc, defaultDoc);
  1072. }
  1073. if (nativeVersion < 19)
  1074. {
  1075. Debug.LogWarning("UpdateArchive to 19");
  1076. ToVersion19(nativeDoc, defaultDoc);
  1077. }
  1078. if (nativeVersion < 20)
  1079. {
  1080. Debug.LogWarning("UpdateArchive to 20");
  1081. ToVersion20(nativeDoc, defaultDoc);
  1082. }
  1083. if (nativeVersion < 21)
  1084. {
  1085. Debug.LogWarning("UpdateArchive to 21");
  1086. ToVersion21(nativeDoc, defaultDoc);
  1087. }
  1088. return nativeDoc;
  1089. }
  1090. public static XmlDocument ToVersion0(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1091. {
  1092. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 0.ToString();
  1093. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ADPlayTime);
  1094. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1095. return nativeDoc;
  1096. }
  1097. public static XmlDocument ToVersion1(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1098. {
  1099. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 1.ToString();
  1100. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SerialNumber);
  1101. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1102. return nativeDoc;
  1103. }
  1104. public static XmlDocument ToVersion2(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1105. {
  1106. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 2.ToString();
  1107. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NotificationIndex);
  1108. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1109. return nativeDoc;
  1110. }
  1111. public static XmlDocument ToVersion3(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1112. {
  1113. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 3.ToString();
  1114. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NickName);
  1115. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1116. return nativeDoc;
  1117. }
  1118. public static XmlDocument ToVersion4(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1119. {
  1120. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 4.ToString();
  1121. XmlNode xmlNode = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.DressData);
  1122. XmlAttribute attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.LeftLongSleeveSlot));
  1123. attribute.Value="Empty";
  1124. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.LeftShortSleeveSlot));
  1125. attribute.Value="Empty";
  1126. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.RightLongSleeveSlot));
  1127. attribute.Value="Empty";
  1128. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.RightShortSleeveSlot));
  1129. attribute.Value="Empty";
  1130. List<string> sleeveList = GetSleeveListByTop (xmlNode.Attributes [4].Value);
  1131. xmlNode.Attributes [8].Value = sleeveList[0];
  1132. xmlNode.Attributes [9].Value = sleeveList[1];
  1133. xmlNode.Attributes [10].Value = sleeveList[2];
  1134. xmlNode.Attributes [11].Value = sleeveList[3];
  1135. return nativeDoc;
  1136. }
  1137. public static List<string> GetSleeveListByTop(string topName)
  1138. {
  1139. List<string> sleeveList = new List<string>() {"Empty", "Empty", "Empty", "Empty"};
  1140. if (topName == "上衣1")
  1141. {
  1142. sleeveList[1] = "短袖1左";
  1143. sleeveList[3] = "短袖1右";
  1144. }
  1145. else if (topName == "上衣2")
  1146. {
  1147. sleeveList[1] = "短袖2左";
  1148. sleeveList[3] = "短袖2右";
  1149. }
  1150. else if (topName == "上衣3")
  1151. {
  1152. sleeveList[1] = "短袖2左";
  1153. sleeveList[3] = "短袖2右";
  1154. }
  1155. else if (topName == "上衣5")
  1156. {
  1157. sleeveList[1] = "短袖2左";
  1158. sleeveList[3] = "短袖2右";
  1159. }
  1160. else if (topName == "上衣6")
  1161. {
  1162. sleeveList[1] = "短袖6左";
  1163. sleeveList[3] = "短袖6右";
  1164. }
  1165. else if (topName == "上衣7")
  1166. {
  1167. sleeveList[1] = "短袖7左";
  1168. sleeveList[3] = "短袖7右";
  1169. }
  1170. else if (topName == "上衣7(粉)")
  1171. {
  1172. sleeveList[1] = "短袖7粉左";
  1173. sleeveList[3] = "短袖7粉右";
  1174. }
  1175. else if (topName == "上衣12")
  1176. {
  1177. sleeveList[1] = "短袖12左";
  1178. sleeveList[3] = "短袖12右";
  1179. }
  1180. else if (topName == "上衣13")
  1181. {
  1182. sleeveList[1] = "短袖13左";
  1183. sleeveList[3] = "短袖13右";
  1184. }
  1185. else if (topName == "上衣13(紫)")
  1186. {
  1187. sleeveList[1] = "短袖13蓝左";
  1188. sleeveList[3] = "短袖13蓝右";
  1189. }
  1190. else
  1191. {
  1192. sleeveList[0] = "长袖9左";
  1193. sleeveList[2] = "长袖9右";
  1194. }
  1195. return sleeveList;
  1196. }
  1197. public static XmlDocument ToVersion5(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1198. {
  1199. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 5.ToString();
  1200. return nativeDoc;
  1201. }
  1202. public static XmlDocument ToVersion6(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1203. {
  1204. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 6.ToString();
  1205. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NewFlowerFlag);
  1206. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1207. return nativeDoc;
  1208. }
  1209. private static int DefaultFlowerAmt = 1;
  1210. public static XmlDocument ToVersion7(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1211. {
  1212. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 7.ToString();
  1213. XmlNode xmlNode1 = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FlowerList);
  1214. string[] flowerIDs= xmlNode1.Attributes[0].Value.Split(' ');
  1215. xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FlowerAmtList);
  1216. xmlNode1.Attributes[0].Value = "";
  1217. foreach (var flowerID in flowerIDs)
  1218. {
  1219. xmlNode1.Attributes[0].Value += " " + DefaultFlowerAmt;
  1220. }
  1221. xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
  1222. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1223. return nativeDoc;
  1224. }
  1225. public static XmlDocument ToVersion8(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1226. {
  1227. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 8.ToString();
  1228. XmlNode xmlNode0 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.TutorialPlazaRoom);
  1229. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.TutorialIndexPlazaRoom);
  1230. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode0, true));
  1231. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1232. return nativeDoc;
  1233. }
  1234. private static int DefaultAchieveValue = 0;
  1235. public static XmlDocument ToVersion9(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1236. {
  1237. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 9.ToString();
  1238. XmlNode xmlNode = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.AchieveData);
  1239. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateRoomAmt));
  1240. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateChestAmt));
  1241. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateLuckyChestAmt));
  1242. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessColorChestAmt));
  1243. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessNumberChestAmt));
  1244. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.GetChestAwardAmt));
  1245. xmlNode.Attributes[9].Value = DefaultAchieveValue.ToString();
  1246. xmlNode.Attributes[10].Value = DefaultAchieveValue.ToString();
  1247. xmlNode.Attributes[11].Value = DefaultAchieveValue.ToString();
  1248. xmlNode.Attributes[12].Value = DefaultAchieveValue.ToString();
  1249. xmlNode.Attributes[13].Value = DefaultAchieveValue.ToString();
  1250. xmlNode.Attributes[14].Value = DefaultAchieveValue.ToString();
  1251. return nativeDoc;
  1252. }
  1253. public static XmlDocument ToVersion10(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1254. {
  1255. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 10.ToString();
  1256. ChestManager.ClearRefundAndOperateData(nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode));
  1257. return nativeDoc;
  1258. }
  1259. public static XmlDocument ToVersion11(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1260. {
  1261. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 11.ToString();
  1262. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ReplayVersion);
  1263. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1264. return nativeDoc;
  1265. }
  1266. public static XmlDocument ToVersion12(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1267. {
  1268. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 12.ToString();
  1269. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ExtraSlot);
  1270. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1271. return nativeDoc;
  1272. }
  1273. public static XmlDocument ToVersion13(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1274. {
  1275. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 13.ToString();
  1276. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.CurrentMinigameType);
  1277. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1278. return nativeDoc;
  1279. }
  1280. public static XmlDocument ToVersion14(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1281. {
  1282. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 14.ToString();
  1283. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.LastPrivateMessageDate);
  1284. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1285. return nativeDoc;
  1286. }
  1287. public static XmlDocument ToVersion15(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1288. {
  1289. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 15.ToString();
  1290. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.LastApplicantSerialNumber);
  1291. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1292. return nativeDoc;
  1293. }
  1294. public static XmlDocument ToVersion16(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1295. {
  1296. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 16.ToString();
  1297. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial);
  1298. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1299. xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorialIndex);
  1300. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1301. return nativeDoc;
  1302. }
  1303. public static XmlDocument ToVersion17(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1304. {
  1305. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 17.ToString();
  1306. return nativeDoc;
  1307. }
  1308. public static XmlDocument ToVersion18(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1309. {
  1310. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 18.ToString();
  1311. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1312. if (Directory.Exists(persistentFolderPath))
  1313. {
  1314. Directory.Delete(persistentFolderPath, true);
  1315. }
  1316. return nativeDoc;
  1317. }
  1318. public static XmlDocument ToVersion19(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1319. {
  1320. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 19.ToString();
  1321. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1322. if (Directory.Exists(persistentFolderPath))
  1323. {
  1324. Directory.Delete(persistentFolderPath, true);
  1325. }
  1326. return nativeDoc;
  1327. }
  1328. public static XmlDocument ToVersion20(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1329. {
  1330. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 20.ToString();
  1331. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.MinigameCoolFlag);
  1332. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1333. return nativeDoc;
  1334. }
  1335. public static XmlDocument ToVersion21(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1336. {
  1337. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 21.ToString();
  1338. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1339. if (Directory.Exists(persistentFolderPath))
  1340. {
  1341. Directory.Delete(persistentFolderPath, true);
  1342. }
  1343. return nativeDoc;
  1344. }
  1345. }