ConfigManager.cs 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945
  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. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FashionShowTutorial).Attributes[0].Value = TutorialManager.fashionShowTutorial.ToInt().ToString();
  423. if (TutorialManager.findSoloMinigameTutorial || TutorialManager.FindSoloMinigameTutorial)
  424. {
  425. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorial).Attributes[0].Value = "1";
  426. }
  427. else
  428. {
  429. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorial).Attributes[0].Value = "0";
  430. }
  431. if (TutorialManager.findMissingMinigameTutorial || TutorialManager.FindMissingMinigameTutorial)
  432. {
  433. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial).Attributes[0].Value = "1";
  434. }
  435. else
  436. {
  437. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial).Attributes[0].Value = "0";
  438. }
  439. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.TutorialPlazaRoom).Attributes[0].Value = TutorialManager.plazaRoomTutorial.ToInt().ToString();
  440. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.NewplayerTutorialIndex).Attributes[0].Value = TutorialManager.NewplayerTutorialIndex.ToString();
  441. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.MemoryMinigameTutorialIndex).Attributes[0].Value = TutorialManager.MemoryMinigameTutorialIndex.ToString();
  442. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.VisitTutorialIndex).Attributes[0].Value = TutorialManager.VisitTutorialIndex.ToString();
  443. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressroomIndex).Attributes[0].Value = TutorialManager.DressroomTutorialIndex.ToString();
  444. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindSoloMinigameTutorialIndex).Attributes[0].Value = TutorialManager.FindSoloMinigameTutorialIndex.ToString();
  445. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorialIndex).Attributes[0].Value = TutorialManager.FindMissingMinigameTutorialIndex.ToString();
  446. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.TutorialIndexPlazaRoom).Attributes[0].Value = TutorialManager.PlazaRoomTutorialIndex.ToString();
  447. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FashionShowTutorialIndex).Attributes[0].Value = TutorialManager.FashionShowTutorialIndex.ToString();
  448. }
  449. public static void SaveFlowers()
  450. {
  451. XmlAttribute attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerList).Attributes[0];
  452. XmlAttribute attribute1 = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerAmtList).Attributes[0];
  453. attribute.Value = "";
  454. attribute1.Value = "";
  455. foreach (var kv in GardenManager.GetFlowerInfoDict())
  456. {
  457. if (kv.Value.Unlock)
  458. {
  459. attribute.Value += kv.Value.ID + " ";
  460. attribute1.Value += kv.Value.Amount + " ";
  461. }
  462. }
  463. attribute.Value = attribute.Value.Trim(' ');
  464. attribute1.Value = attribute1.Value.Trim(' ');
  465. }
  466. public static void SaveConfigDocument()
  467. {
  468. if (Initializer.Inited)
  469. {
  470. SaveSkillList();
  471. SaveAchieve();
  472. SaveDress();
  473. SavePlantList();
  474. SaveDatas();
  475. SaveFlowers();
  476. ChestManager.SaveToConfig();
  477. }
  478. }
  479. public static void SaveConfigDocumentToDisk()
  480. {
  481. if (Initializer.Inited)
  482. {
  483. XmlDocument doc = new XmlDocument();
  484. doc.LoadXml(ConfigDocument.OuterXml);
  485. Auxiliary.EncryptXml(doc);
  486. StreamWriter sw = new StreamWriter(ConfigPath);
  487. sw.Write(doc.OuterXml);
  488. sw.Close();
  489. byte[] bytes = File.ReadAllBytes(ConfigPath);
  490. //byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
  491. MD5 md5 = new MD5CryptoServiceProvider();
  492. PlayerPrefs.SetString(Lib.ConfigPrefs, Auxiliary.ToString(md5.ComputeHash(bytes)));
  493. }
  494. }
  495. public static void ResetConfigDocument()
  496. {
  497. ConfigRootNode.SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = ConfigReplayVersion.ToString();
  498. SaveConfigDocument();
  499. Manager.UploadConfigFlag = true;
  500. Manager.DownloadConfigFlag = true;
  501. SaveConfigDocumentToDisk();
  502. DelayCall.Call
  503. (
  504. 1,
  505. () =>
  506. {
  507. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__La_Lab0), null, null, () => { Application.Quit(); }, null, false);
  508. }
  509. );
  510. }
  511. public static int GetIntFormConfig(string node)
  512. {
  513. return int.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  514. }
  515. public static bool GetBoolFormConfig(string node)
  516. {
  517. return int.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
  518. }
  519. public static float GetFloatFormConfig(string node)
  520. {
  521. return float.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  522. }
  523. public static string GetStringFormConfig(string node)
  524. {
  525. return ConfigRootNode.SelectSingleNode(node).Attributes[0].Value;
  526. }
  527. public static double GetDoubleFormConfig(string node)
  528. {
  529. return double.Parse(ConfigRootNode.SelectSingleNode(node).Attributes[0].Value);
  530. }
  531. public static void SaveIntToConfig(string node, int value)
  532. {
  533. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  534. }
  535. public static void SaveBoolToConfig(string node, bool value)
  536. {
  537. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
  538. }
  539. public static void SaveFloatToConfig(string node, float value)
  540. {
  541. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  542. }
  543. public static void SaveStringToConfig(string node, string value)
  544. {
  545. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value;
  546. }
  547. public static void SaveDoubleToConfig(string node, double value)
  548. {
  549. ConfigRootNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  550. }
  551. public static List<int> GetIntList(char splitChar, string nodeName, List<int> defaultList)
  552. {
  553. return Auxiliary.StringToInts(splitChar, ConfigRootNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  554. }
  555. public static List<string> GetStringList(char splitChar, string nodeName, List<string> defaultList)
  556. {
  557. return Auxiliary.StringToStrings(splitChar, ConfigRootNode.SelectSingleNode(nodeName).Attributes[0].Value, defaultList);
  558. }
  559. public static List<int> GetDressList()
  560. {
  561. List<int> list = new List<int>();
  562. XmlAttributeCollection attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressList).Attributes;
  563. return Auxiliary.StringToInts(' ', attribute[0].Value, list);
  564. }
  565. public static List<int> GetDressDataIDs(Player player)
  566. {
  567. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  568. //{
  569. // Debug.LogWarning(VARIABLE.Key);
  570. //}
  571. List<int> dressDataIDs = new List<int>();
  572. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Head]);
  573. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Dress]);
  574. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Shoe]);
  575. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.HeadWear]);
  576. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Top]);
  577. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Eye]);
  578. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Mouse]);
  579. dressDataIDs.Add(PlayerManager.CloseIDDictionary[player.Wing]);
  580. return dressDataIDs;
  581. }
  582. public static List<int> GetDressDataIDs(List<string> dressdataNames)
  583. {
  584. //foreach (var VARIABLE in ManaPlayer.CloseIDDic)
  585. //{
  586. // Debug.LogWarning(VARIABLE.Key);
  587. //}
  588. List<int> dressDataIDs = new List<int>();
  589. int index = 0;
  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. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  597. dressDataIDs.Add(PlayerManager.CloseIDDictionary[dressdataNames[index++]]);
  598. return dressDataIDs;
  599. }
  600. public static List<int> GetDressDataIDs(ISFSObject parameter)
  601. {
  602. List<int> ids = parameter.GetIntArray(InfoLabel.Close.GetHashString()).ToList();
  603. return ids;
  604. }
  605. public static List<string> GetDressData(SFSObject parameter)
  606. {
  607. List<int> ids = GetDressDataIDs(parameter);
  608. List<string> dressData = new List<string>();
  609. foreach (var id in ids)
  610. {
  611. dressData.Add(PlayerManager.CloseItemDictionary[id].ArmatureName);
  612. }
  613. return dressData;
  614. }
  615. public static List<string> GetDressData(XmlNode node = null)
  616. {
  617. XmlNode xmlNode;
  618. if (node == null)
  619. {
  620. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.DressData);
  621. }
  622. else
  623. {
  624. xmlNode = node.SelectSingleNode(PlayerConfigLabel.DressData);
  625. }
  626. List<string> dataList = new List<string>();
  627. if (xmlNode != null && xmlNode.Attributes.Count == 12)
  628. {
  629. dataList.Add(xmlNode.Attributes[0].Value);
  630. dataList.Add(xmlNode.Attributes[1].Value);
  631. dataList.Add(xmlNode.Attributes[2].Value);
  632. dataList.Add(xmlNode.Attributes[3].Value);
  633. dataList.Add(xmlNode.Attributes[4].Value);
  634. dataList.Add(xmlNode.Attributes[5].Value);
  635. dataList.Add(xmlNode.Attributes[6].Value);
  636. dataList.Add(xmlNode.Attributes[7].Value);
  637. dataList.Add(xmlNode.Attributes[8].Value);
  638. dataList.Add(xmlNode.Attributes[9].Value);
  639. dataList.Add(xmlNode.Attributes[10].Value);
  640. dataList.Add(xmlNode.Attributes[11].Value);
  641. //dataList[8] = "长袖9左";
  642. //dataList[9] = "Empty";
  643. //dataList[10] = "长袖9右";
  644. //dataList[11] = "Empty";
  645. }
  646. else if(xmlNode != null && xmlNode.Attributes.Count == 8)
  647. {
  648. dataList.Add(xmlNode.Attributes[0].Value);
  649. dataList.Add(xmlNode.Attributes[1].Value);
  650. dataList.Add(xmlNode.Attributes[2].Value);
  651. dataList.Add(xmlNode.Attributes[3].Value);
  652. dataList.Add(xmlNode.Attributes[4].Value);
  653. dataList.Add(xmlNode.Attributes[5].Value);
  654. dataList.Add(xmlNode.Attributes[6].Value);
  655. dataList.Add(xmlNode.Attributes[7].Value);
  656. dataList.AddRange (GetSleeveListByTop(xmlNode.Attributes[4].Value));
  657. }
  658. else
  659. {
  660. float rate = Random.Range(0f, 1f);
  661. if (rate < 0.33f)
  662. {
  663. dataList.Add("脑壳1");
  664. dataList.Add("裙子1");
  665. dataList.Add("鞋子1");
  666. dataList.Add("头饰品1");
  667. dataList.Add("上衣1");
  668. dataList.Add("眼睛1");
  669. dataList.Add("嘴巴1");
  670. dataList.Add("Empty");
  671. dataList.Add("Empty");
  672. dataList.Add("短袖1左");
  673. dataList.Add("Empty");
  674. dataList.Add("短袖1右");
  675. }
  676. else if (rate < 0.66f)
  677. {
  678. dataList.Add("脑壳2");
  679. dataList.Add("裙子2");
  680. dataList.Add("鞋子2");
  681. dataList.Add("头饰品2");
  682. dataList.Add("上衣2");
  683. dataList.Add("眼睛2");
  684. dataList.Add("嘴巴2");
  685. dataList.Add("Empty");
  686. dataList.Add("Empty");
  687. dataList.Add("短袖2左");
  688. dataList.Add("Empty");
  689. dataList.Add("短袖2右");
  690. }
  691. else
  692. {
  693. dataList.Add("脑壳3");
  694. dataList.Add("裙子3");
  695. dataList.Add("鞋子3");
  696. dataList.Add("头饰品3");
  697. dataList.Add("上衣3");
  698. dataList.Add("眼睛3");
  699. dataList.Add("嘴巴3");
  700. dataList.Add("Empty");
  701. dataList.Add("Empty");
  702. dataList.Add("短袖2左");
  703. dataList.Add("Empty");
  704. dataList.Add("短袖2右");
  705. }
  706. }
  707. return dataList;
  708. }
  709. public static List<int> GetFlowerList()
  710. {
  711. List<int> list = new List<int>();
  712. XmlAttributeCollection attribute = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.FlowerList).Attributes;
  713. return Auxiliary.StringToInts(' ', attribute[0].Value, list);
  714. }
  715. public static List<int> GetLockAchieveIDs()
  716. {
  717. return Auxiliary.StringToInts(' ', GetStringFormConfig(PlayerConfigLabel.AchieveList), new List<int>());
  718. }
  719. public static List<double> GetAchieveValues()
  720. {
  721. List<double> dataList = new List<double>();
  722. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[0].Value));
  723. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[1].Value));
  724. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[2].Value));
  725. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[3].Value));
  726. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[4].Value));
  727. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[5].Value));
  728. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[6].Value));
  729. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[7].Value));
  730. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[8].Value));
  731. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[9].Value));
  732. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[10].Value));
  733. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[11].Value));
  734. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[12].Value));
  735. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[13].Value));
  736. dataList.Add(double.Parse(ConfigRootNode.SelectSingleNode(PlayerConfigLabel.AchieveData).Attributes[14].Value));
  737. return dataList;
  738. }
  739. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  740. {
  741. List<KV<int, int>> list = new List<KV<int, int>>();
  742. XmlNode xmlNode;
  743. if (node == null)
  744. {
  745. xmlNode = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.PlantList);
  746. }
  747. else
  748. {
  749. xmlNode = node.SelectSingleNode(PlayerConfigLabel.PlantList);
  750. }
  751. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  752. {
  753. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  754. for (int i = 0; i < strings.Length; i++)
  755. {
  756. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  757. }
  758. }
  759. return list;
  760. }
  761. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  762. {
  763. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  764. XmlNodeList xmlNodeList;
  765. if (node == null)
  766. {
  767. xmlNodeList = ConfigRootNode.SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
  768. }
  769. else
  770. {
  771. xmlNodeList = node.SelectSingleNode(PlayerConfigLabel.SkillList).ChildNodes;
  772. }
  773. for (int i = 0; i < xmlNodeList.Count; i++)
  774. {
  775. attributeList.Add(xmlNodeList[i].Attributes);
  776. }
  777. return attributeList;
  778. }
  779. public static List<string> GetOfflineConfig()
  780. {
  781. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.OfflineConfig, Folder.Config);
  782. XmlDocument xmlDoc = new XmlDocument();
  783. xmlDoc.LoadXml(textAsset.text);
  784. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  785. List<string> strList = new List<string>()
  786. {
  787. xmlNode.Attributes[1].Value,
  788. xmlNode.Attributes[2].Value,
  789. xmlNode.Attributes[3].Value,
  790. };
  791. return strList;
  792. }
  793. public static XmlAttributeCollection GetVisitConfig()
  794. {
  795. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.VisitConfig, Folder.Config);
  796. XmlDocument xmlDoc = new XmlDocument();
  797. xmlDoc.LoadXml(textAsset.text);
  798. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  799. return xmlNode.Attributes;
  800. }
  801. public static XmlAttributeCollection GetPlazaRoomConfig()
  802. {
  803. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PlazaroomConfig, Folder.Config);
  804. XmlDocument xmlDoc = new XmlDocument();
  805. xmlDoc.LoadXml(textAsset.text);
  806. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  807. return xmlNode.Attributes;
  808. }
  809. public static XmlAttributeCollection GetAwardConfig()
  810. {
  811. TextAsset textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AwardConfig, Folder.Config);
  812. XmlDocument xmlDoc = new XmlDocument();
  813. xmlDoc.LoadXml(textAsset.text);
  814. XmlNode xmlNode = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectSingleNode(ConfigLabel.ChildNode);
  815. return xmlNode.Attributes;
  816. }
  817. public static List<XmlAttributeCollection> GetIAPConfig()
  818. {
  819. TextAsset textAsset;
  820. XmlNodeList xmlNodeList;
  821. XmlDocument xmlDoc = new XmlDocument();
  822. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  823. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.IAPConfig, Folder.Config);
  824. xmlDoc.LoadXml(textAsset.text);
  825. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  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> GetSkillConfig()
  833. {
  834. TextAsset textAsset;
  835. XmlDocument xmlDoc = new XmlDocument();
  836. List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
  837. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  838. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.PackConfig, Folder.Config);
  839. xmlDoc.LoadXml(textAsset.text);
  840. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  841. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.SkillConfig, Folder.Config);
  842. xmlDoc.LoadXml(textAsset.text);
  843. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  844. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AbilityConfig, Folder.Config);
  845. xmlDoc.LoadXml(textAsset.text);
  846. xmlNodeList.Add(xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode));
  847. for (int i = 0; i < xmlNodeList.Count; i++)
  848. {
  849. for (int j = 0; j < xmlNodeList[i].Count; j++)
  850. {
  851. attributeList.Add(xmlNodeList[i][j].Attributes);
  852. }
  853. }
  854. return attributeList;
  855. }
  856. public static List<XmlAttributeCollection> GetSignConfig()
  857. {
  858. TextAsset textAsset;
  859. XmlNodeList xmlNodeList;
  860. XmlDocument xmlDoc = new XmlDocument();
  861. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  862. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.SigninConfig, Folder.Config);
  863. xmlDoc.LoadXml(textAsset.text);
  864. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  865. for (int i = 0; i < xmlNodeList.Count; i++)
  866. {
  867. attributeList.Add(xmlNodeList[i].Attributes);
  868. }
  869. return attributeList;
  870. }
  871. public static List<XmlAttributeCollection> GetFlowerConfig(TextAsset textAsset = null)
  872. {
  873. XmlNodeList xmlNodeList;
  874. XmlDocument xmlDoc = new XmlDocument();
  875. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  876. if (textAsset == null)
  877. {
  878. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.FlowerConfig, Folder.Config);
  879. }
  880. xmlDoc.LoadXml(textAsset.text);
  881. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  882. for (int i = 0; i < xmlNodeList.Count; i++)
  883. {
  884. attributeList.Add(xmlNodeList[i].Attributes);
  885. }
  886. return attributeList;
  887. }
  888. public static List<XmlAttributeCollection> GetLotteryConfig()
  889. {
  890. TextAsset textAsset;
  891. XmlNodeList xmlNodeList;
  892. XmlDocument xmlDoc = new XmlDocument();
  893. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  894. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.LotteryConfig, Folder.Config);
  895. xmlDoc.LoadXml(textAsset.text);
  896. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  897. for (int i = 0; i < xmlNodeList.Count; i++)
  898. {
  899. attributeList.Add(xmlNodeList[i].Attributes);
  900. }
  901. return attributeList;
  902. }
  903. public static List<XmlAttributeCollection> GetAchieveConfig()
  904. {
  905. TextAsset textAsset;
  906. XmlNodeList xmlNodeList;
  907. XmlDocument xmlDoc = new XmlDocument();
  908. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  909. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.AchieveConfig, Folder.Config);
  910. xmlDoc.LoadXml(textAsset.text);
  911. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  912. for (int i = 0; i < xmlNodeList.Count; i++)
  913. {
  914. attributeList.Add(xmlNodeList[i].Attributes);
  915. }
  916. return attributeList;
  917. }
  918. public static List<XmlAttributeCollection> GetDressRoomConfig(TextAsset textAsset = null)
  919. {
  920. XmlNodeList xmlNodeList;
  921. XmlDocument xmlDoc = new XmlDocument();
  922. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  923. if (textAsset == null)
  924. {
  925. textAsset = ResourceManager.Load<TextAsset>(ResourceLabel.DressroomConfig, Folder.Config);
  926. }
  927. xmlDoc.LoadXml(textAsset.text);
  928. xmlNodeList = xmlDoc.SelectSingleNode(ConfigLabel.RootNode).SelectNodes(ConfigLabel.ChildNode);
  929. for (int i = 0; i < xmlNodeList.Count; i++)
  930. {
  931. attributeList.Add(xmlNodeList[i].Attributes);
  932. }
  933. return attributeList;
  934. }
  935. public static int GetGardenLevel(XmlDocument xmlDocument)
  936. {
  937. XmlNodeList nodeList = xmlDocument.SelectNodes(PlayerConfigLabel.RootNode + "/" + PlayerConfigLabel.SkillList + "/" + PlayerConfigLabel.Skill);
  938. for (int i = 0; i < nodeList.Count; i++)
  939. {
  940. if (nodeList[i].Attributes[0].Value == "Ability1")
  941. {
  942. return int.Parse(nodeList[i].Attributes[3].Value);
  943. }
  944. }
  945. return -1;
  946. }
  947. public static int GetConfigVersion(XmlDocument xmlDocument)
  948. {
  949. return int.Parse(xmlDocument.SelectSingleNode(PlayerConfigLabel.RootNode + "/" + PlayerConfigLabel.Version).Attributes[0].Value);
  950. }
  951. public static List<string> GetDefaultDressDatas()
  952. {
  953. List<string> defaultDressDatas = new List<string>();
  954. defaultDressDatas.Add("脑壳-缺失");
  955. defaultDressDatas.Add("裙子-缺失");
  956. defaultDressDatas.Add("鞋子-缺失");
  957. defaultDressDatas.Add("头饰-缺失");
  958. defaultDressDatas.Add("上衣-缺失");
  959. defaultDressDatas.Add("眼睛1");
  960. defaultDressDatas.Add("嘴巴1");
  961. defaultDressDatas.Add("翅膀-缺失");
  962. defaultDressDatas.Add("Empty");
  963. defaultDressDatas.Add("Empty");
  964. defaultDressDatas.Add("Empty");
  965. defaultDressDatas.Add("Empty");
  966. //defaultDressDatas.Add("脑壳1");
  967. //defaultDressDatas.Add("裙子1");
  968. //defaultDressDatas.Add("鞋子1");
  969. //defaultDressDatas.Add("头饰品1");
  970. //defaultDressDatas.Add("上衣1");
  971. //defaultDressDatas.Add("眼睛1");
  972. //defaultDressDatas.Add("嘴巴1");
  973. //defaultDressDatas.Add("Empty");
  974. //defaultDressDatas.Add("Empty");
  975. //defaultDressDatas.Add("短袖2左");
  976. //defaultDressDatas.Add("Empty");
  977. //defaultDressDatas.Add("短袖2右");
  978. return defaultDressDatas;
  979. }
  980. public static XmlDocument GetXmlDocument(string ConfigName)
  981. {
  982. TextAsset textAsset = ResourceManager.Load<TextAsset>(ConfigName, Folder.Config);
  983. XmlDocument xmlDocument = new XmlDocument();
  984. xmlDocument.LoadXml(textAsset.text);
  985. return xmlDocument;
  986. }
  987. //玩家存档版本大于默认存档版本时需要清空
  988. //玩家存档版本小于默认存档版本时需要更新
  989. //玩家存档版本等于ReplayVersion时需要标记为重玩
  990. public static XmlDocument UpdateConfigDocument(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
  991. {
  992. if (nativeVersion < 0)
  993. {
  994. Debug.LogWarning("UpdateArchive to 0");
  995. ToVersion0(nativeDoc, defaultDoc);
  996. }
  997. if (nativeVersion < 1)
  998. {
  999. Debug.LogWarning("UpdateArchive to 1");
  1000. ToVersion1(nativeDoc, defaultDoc);
  1001. }
  1002. if (nativeVersion < 2)
  1003. {
  1004. Debug.LogWarning("UpdateArchive to 2");
  1005. ToVersion2(nativeDoc, defaultDoc);
  1006. }
  1007. if (nativeVersion < 3)
  1008. {
  1009. Debug.LogWarning("UpdateArchive to 3");
  1010. ToVersion3(nativeDoc, defaultDoc);
  1011. }
  1012. if (nativeVersion < 4)
  1013. {
  1014. Debug.LogWarning("UpdateArchive to 4");
  1015. ToVersion4(nativeDoc, defaultDoc);
  1016. }
  1017. if (nativeVersion < 5)
  1018. {
  1019. Debug.LogWarning("UpdateArchive to 5");
  1020. ToVersion5(nativeDoc, defaultDoc);
  1021. }
  1022. if (nativeVersion < 6)
  1023. {
  1024. Debug.LogWarning("UpdateArchive to 6");
  1025. ToVersion6(nativeDoc, defaultDoc);
  1026. }
  1027. if (nativeVersion < 7)
  1028. {
  1029. Debug.LogWarning("UpdateArchive to 7");
  1030. ToVersion7(nativeDoc, defaultDoc);
  1031. }
  1032. if (nativeVersion < 8)
  1033. {
  1034. Debug.LogWarning("UpdateArchive to 8");
  1035. ToVersion8(nativeDoc, defaultDoc);
  1036. }
  1037. if (nativeVersion < 9)
  1038. {
  1039. Debug.LogWarning("UpdateArchive to 9");
  1040. ToVersion9(nativeDoc, defaultDoc);
  1041. }
  1042. if (nativeVersion < 10)
  1043. {
  1044. Debug.LogWarning("UpdateArchive to 10");
  1045. ToVersion10(nativeDoc, defaultDoc);
  1046. }
  1047. if (nativeVersion < 11)
  1048. {
  1049. Debug.LogWarning("UpdateArchive to 11");
  1050. ToVersion11(nativeDoc, defaultDoc);
  1051. }
  1052. if (nativeVersion < 12)
  1053. {
  1054. Debug.LogWarning("UpdateArchive to 12");
  1055. ToVersion12(nativeDoc, defaultDoc);
  1056. }
  1057. if (nativeVersion < 13)
  1058. {
  1059. Debug.LogWarning("UpdateArchive to 13");
  1060. ToVersion13(nativeDoc, defaultDoc);
  1061. }
  1062. if (nativeVersion < 14)
  1063. {
  1064. Debug.LogWarning("UpdateArchive to 14");
  1065. ToVersion14(nativeDoc, defaultDoc);
  1066. }
  1067. if (nativeVersion < 15)
  1068. {
  1069. Debug.LogWarning("UpdateArchive to 15");
  1070. ToVersion15(nativeDoc, defaultDoc);
  1071. }
  1072. if (nativeVersion < 16)
  1073. {
  1074. Debug.LogWarning("UpdateArchive to 16");
  1075. ToVersion16(nativeDoc, defaultDoc);
  1076. }
  1077. if (nativeVersion < 17)
  1078. {
  1079. Debug.LogWarning("UpdateArchive to 17");
  1080. ToVersion17(nativeDoc, defaultDoc);
  1081. }
  1082. if (nativeVersion < 18)
  1083. {
  1084. Debug.LogWarning("UpdateArchive to 18");
  1085. ToVersion18(nativeDoc, defaultDoc);
  1086. }
  1087. if (nativeVersion < 19)
  1088. {
  1089. Debug.LogWarning("UpdateArchive to 19");
  1090. ToVersion19(nativeDoc, defaultDoc);
  1091. }
  1092. if (nativeVersion < 20)
  1093. {
  1094. Debug.LogWarning("UpdateArchive to 20");
  1095. ToVersion20(nativeDoc, defaultDoc);
  1096. }
  1097. if (nativeVersion < 21)
  1098. {
  1099. Debug.LogWarning("UpdateArchive to 21");
  1100. ToVersion21(nativeDoc, defaultDoc);
  1101. }
  1102. if (nativeVersion < 22)
  1103. {
  1104. Debug.LogWarning("UpdateArchive to 22");
  1105. ToVersion22(nativeDoc, defaultDoc);
  1106. }
  1107. if (nativeVersion < 23)
  1108. {
  1109. Debug.LogWarning("UpdateArchive to 23");
  1110. ToVersion23(nativeDoc, defaultDoc);
  1111. }
  1112. if (nativeVersion < 24)
  1113. {
  1114. Debug.LogWarning("UpdateArchive to 24");
  1115. ToVersion24(nativeDoc, defaultDoc);
  1116. }
  1117. if (nativeVersion < 25)
  1118. {
  1119. Debug.LogWarning("UpdateArchive to 25");
  1120. ToVersion25(nativeDoc, defaultDoc);
  1121. }
  1122. if (nativeVersion < 26)
  1123. {
  1124. Debug.LogWarning("UpdateArchive to 26");
  1125. ToVersion26(nativeDoc, defaultDoc);
  1126. }
  1127. if (nativeVersion < 28)
  1128. {
  1129. Debug.LogWarning("UpdateArchive to 28");
  1130. ToVersion28(nativeDoc, defaultDoc);
  1131. }
  1132. if (nativeVersion < 29)
  1133. {
  1134. Debug.LogWarning("UpdateArchive to 29");
  1135. ToVersion29(nativeDoc, defaultDoc);
  1136. }
  1137. if (nativeVersion < 30)
  1138. {
  1139. Debug.LogWarning("UpdateArchive to 30");
  1140. ToVersion30(nativeDoc, defaultDoc);
  1141. }
  1142. return nativeDoc;
  1143. }
  1144. public static XmlDocument ToVersion0(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1145. {
  1146. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 0.ToString();
  1147. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ADPlayTime);
  1148. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1149. return nativeDoc;
  1150. }
  1151. public static XmlDocument ToVersion1(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1152. {
  1153. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 1.ToString();
  1154. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.SerialNumber);
  1155. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1156. return nativeDoc;
  1157. }
  1158. public static XmlDocument ToVersion2(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1159. {
  1160. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 2.ToString();
  1161. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NotificationIndex);
  1162. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1163. return nativeDoc;
  1164. }
  1165. public static XmlDocument ToVersion3(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1166. {
  1167. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 3.ToString();
  1168. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NickName);
  1169. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1170. return nativeDoc;
  1171. }
  1172. public static XmlDocument ToVersion4(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1173. {
  1174. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 4.ToString();
  1175. XmlNode xmlNode = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.DressData);
  1176. XmlAttribute attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.LeftLongSleeveSlot));
  1177. attribute.Value="Empty";
  1178. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.LeftShortSleeveSlot));
  1179. attribute.Value="Empty";
  1180. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.RightLongSleeveSlot));
  1181. attribute.Value="Empty";
  1182. attribute = xmlNode.Attributes.Append (nativeDoc.CreateAttribute (PlayerConfigLabel.RightShortSleeveSlot));
  1183. attribute.Value="Empty";
  1184. List<string> sleeveList = GetSleeveListByTop (xmlNode.Attributes [4].Value);
  1185. xmlNode.Attributes [8].Value = sleeveList[0];
  1186. xmlNode.Attributes [9].Value = sleeveList[1];
  1187. xmlNode.Attributes [10].Value = sleeveList[2];
  1188. xmlNode.Attributes [11].Value = sleeveList[3];
  1189. return nativeDoc;
  1190. }
  1191. public static List<string> GetSleeveListByTop(string topName)
  1192. {
  1193. List<string> sleeveList = new List<string>() {"Empty", "Empty", "Empty", "Empty"};
  1194. if (topName == "上衣1")
  1195. {
  1196. sleeveList[1] = "短袖1左";
  1197. sleeveList[3] = "短袖1右";
  1198. }
  1199. else if (topName == "上衣2")
  1200. {
  1201. sleeveList[1] = "短袖2左";
  1202. sleeveList[3] = "短袖2右";
  1203. }
  1204. else if (topName == "上衣3")
  1205. {
  1206. sleeveList[1] = "短袖2左";
  1207. sleeveList[3] = "短袖2右";
  1208. }
  1209. else if (topName == "上衣5")
  1210. {
  1211. sleeveList[1] = "短袖2左";
  1212. sleeveList[3] = "短袖2右";
  1213. }
  1214. else if (topName == "上衣6")
  1215. {
  1216. sleeveList[1] = "短袖6左";
  1217. sleeveList[3] = "短袖6右";
  1218. }
  1219. else if (topName == "上衣7")
  1220. {
  1221. sleeveList[1] = "短袖7左";
  1222. sleeveList[3] = "短袖7右";
  1223. }
  1224. else if (topName == "上衣7(粉)")
  1225. {
  1226. sleeveList[1] = "短袖7粉左";
  1227. sleeveList[3] = "短袖7粉右";
  1228. }
  1229. else if (topName == "上衣12")
  1230. {
  1231. sleeveList[1] = "短袖12左";
  1232. sleeveList[3] = "短袖12右";
  1233. }
  1234. else if (topName == "上衣13")
  1235. {
  1236. sleeveList[1] = "短袖13左";
  1237. sleeveList[3] = "短袖13右";
  1238. }
  1239. else if (topName == "上衣13(紫)")
  1240. {
  1241. sleeveList[1] = "短袖13蓝左";
  1242. sleeveList[3] = "短袖13蓝右";
  1243. }
  1244. else
  1245. {
  1246. sleeveList[0] = "长袖9左";
  1247. sleeveList[2] = "长袖9右";
  1248. }
  1249. return sleeveList;
  1250. }
  1251. public static XmlDocument ToVersion5(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1252. {
  1253. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 5.ToString();
  1254. return nativeDoc;
  1255. }
  1256. public static XmlDocument ToVersion6(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1257. {
  1258. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 6.ToString();
  1259. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.NewFlowerFlag);
  1260. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1261. return nativeDoc;
  1262. }
  1263. private static int DefaultFlowerAmt = 1;
  1264. public static XmlDocument ToVersion7(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1265. {
  1266. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 7.ToString();
  1267. XmlNode xmlNode1 = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FlowerList);
  1268. string[] flowerIDs= xmlNode1.Attributes[0].Value.Split(' ');
  1269. xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FlowerAmtList);
  1270. xmlNode1.Attributes[0].Value = "";
  1271. foreach (var flowerID in flowerIDs)
  1272. {
  1273. xmlNode1.Attributes[0].Value += " " + DefaultFlowerAmt;
  1274. }
  1275. xmlNode1.Attributes[0].Value = xmlNode1.Attributes[0].Value.TrimStart();
  1276. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1277. return nativeDoc;
  1278. }
  1279. public static XmlDocument ToVersion8(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1280. {
  1281. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 8.ToString();
  1282. XmlNode xmlNode0 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.TutorialPlazaRoom);
  1283. XmlNode xmlNode1 = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.TutorialIndexPlazaRoom);
  1284. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode0, true));
  1285. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode1, true));
  1286. return nativeDoc;
  1287. }
  1288. private static int DefaultAchieveValue = 0;
  1289. public static XmlDocument ToVersion9(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1290. {
  1291. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 9.ToString();
  1292. XmlNode xmlNode = nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.AchieveData);
  1293. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateRoomAmt));
  1294. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateChestAmt));
  1295. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateLuckyChestAmt));
  1296. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessColorChestAmt));
  1297. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.CreateGuessNumberChestAmt));
  1298. xmlNode.Attributes.Append(nativeDoc.CreateAttribute(PlayerConfigLabel.GetChestAwardAmt));
  1299. xmlNode.Attributes[9].Value = DefaultAchieveValue.ToString();
  1300. xmlNode.Attributes[10].Value = DefaultAchieveValue.ToString();
  1301. xmlNode.Attributes[11].Value = DefaultAchieveValue.ToString();
  1302. xmlNode.Attributes[12].Value = DefaultAchieveValue.ToString();
  1303. xmlNode.Attributes[13].Value = DefaultAchieveValue.ToString();
  1304. xmlNode.Attributes[14].Value = DefaultAchieveValue.ToString();
  1305. return nativeDoc;
  1306. }
  1307. public static XmlDocument ToVersion10(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1308. {
  1309. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 10.ToString();
  1310. ChestManager.ClearRefundAndOperateData(nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode));
  1311. return nativeDoc;
  1312. }
  1313. public static XmlDocument ToVersion11(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1314. {
  1315. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 11.ToString();
  1316. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ReplayVersion);
  1317. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1318. return nativeDoc;
  1319. }
  1320. public static XmlDocument ToVersion12(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1321. {
  1322. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 12.ToString();
  1323. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.ExtraSlot);
  1324. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1325. return nativeDoc;
  1326. }
  1327. public static XmlDocument ToVersion13(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1328. {
  1329. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 13.ToString();
  1330. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.CurrentMinigameType);
  1331. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1332. return nativeDoc;
  1333. }
  1334. public static XmlDocument ToVersion14(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1335. {
  1336. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 14.ToString();
  1337. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.LastPrivateMessageDate);
  1338. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1339. return nativeDoc;
  1340. }
  1341. public static XmlDocument ToVersion15(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1342. {
  1343. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 15.ToString();
  1344. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.LastApplicantSerialNumber);
  1345. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1346. return nativeDoc;
  1347. }
  1348. public static XmlDocument ToVersion16(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1349. {
  1350. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 16.ToString();
  1351. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorial);
  1352. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1353. xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FindMissingMinigameTutorialIndex);
  1354. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1355. return nativeDoc;
  1356. }
  1357. public static XmlDocument ToVersion17(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1358. {
  1359. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 17.ToString();
  1360. return nativeDoc;
  1361. }
  1362. public static XmlDocument ToVersion18(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1363. {
  1364. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 18.ToString();
  1365. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1366. if (Directory.Exists(persistentFolderPath))
  1367. {
  1368. Directory.Delete(persistentFolderPath, true);
  1369. }
  1370. return nativeDoc;
  1371. }
  1372. public static XmlDocument ToVersion19(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1373. {
  1374. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 19.ToString();
  1375. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1376. if (Directory.Exists(persistentFolderPath))
  1377. {
  1378. Directory.Delete(persistentFolderPath, true);
  1379. }
  1380. return nativeDoc;
  1381. }
  1382. public static XmlDocument ToVersion20(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1383. {
  1384. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 20.ToString();
  1385. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.MinigameCoolFlag);
  1386. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1387. return nativeDoc;
  1388. }
  1389. public static XmlDocument ToVersion21(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1390. {
  1391. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 21.ToString();
  1392. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1393. if (Directory.Exists(persistentFolderPath))
  1394. {
  1395. Directory.Delete(persistentFolderPath, true);
  1396. }
  1397. return nativeDoc;
  1398. }
  1399. public static XmlDocument ToVersion22(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1400. {
  1401. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 22.ToString();
  1402. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1403. if (Directory.Exists(persistentFolderPath))
  1404. {
  1405. Directory.Delete(persistentFolderPath, true);
  1406. }
  1407. return nativeDoc;
  1408. }
  1409. public static XmlDocument ToVersion23(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1410. {
  1411. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 23.ToString();
  1412. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1413. if (Directory.Exists(persistentFolderPath))
  1414. {
  1415. Directory.Delete(persistentFolderPath, true);
  1416. }
  1417. return nativeDoc;
  1418. }
  1419. public static XmlDocument ToVersion24(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1420. {
  1421. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 24.ToString();
  1422. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1423. if (Directory.Exists(persistentFolderPath))
  1424. {
  1425. Directory.Delete(persistentFolderPath, true);
  1426. }
  1427. return nativeDoc;
  1428. }
  1429. public static XmlDocument ToVersion25(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1430. {
  1431. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 25.ToString();
  1432. XmlNode xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FashionShowTutorial);
  1433. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1434. xmlNode = defaultDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.FashionShowTutorialIndex);
  1435. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).AppendChild(nativeDoc.ImportNode(xmlNode, true));
  1436. return nativeDoc;
  1437. }
  1438. public static XmlDocument ToVersion26(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1439. {
  1440. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 26.ToString();
  1441. return nativeDoc;
  1442. }
  1443. public static XmlDocument ToVersion27(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1444. {
  1445. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 27.ToString();
  1446. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1447. if (Directory.Exists(persistentFolderPath))
  1448. {
  1449. Directory.Delete(persistentFolderPath, true);
  1450. }
  1451. return nativeDoc;
  1452. }
  1453. public static XmlDocument ToVersion28(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1454. {
  1455. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 28.ToString();
  1456. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1457. if (Directory.Exists(persistentFolderPath))
  1458. {
  1459. Directory.Delete(persistentFolderPath, true);
  1460. }
  1461. return nativeDoc;
  1462. }
  1463. public static XmlDocument ToVersion29(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1464. {
  1465. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 29.ToString();
  1466. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1467. if (Directory.Exists(persistentFolderPath))
  1468. {
  1469. Directory.Delete(persistentFolderPath, true);
  1470. }
  1471. return nativeDoc;
  1472. }
  1473. public static XmlDocument ToVersion30(XmlDocument nativeDoc, XmlDocument defaultDoc)
  1474. {
  1475. nativeDoc.SelectSingleNode(PlayerConfigLabel.RootNode).SelectSingleNode(PlayerConfigLabel.Version).Attributes[0].Value = 30.ToString();
  1476. string persistentFolderPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}HotUpdate";
  1477. if (Directory.Exists(persistentFolderPath))
  1478. {
  1479. Directory.Delete(persistentFolderPath, true);
  1480. }
  1481. return nativeDoc;
  1482. }
  1483. }