Data.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. using UnityEngine;
  2. using System;
  3. using System.IO;
  4. using System.Xml;
  5. using System.Text;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. public class Data
  9. {
  10. #region 变量
  11. public static XmlNode PlayerNode
  12. {
  13. get
  14. {
  15. if (_PlayerNode == null)
  16. {
  17. _PlayerNode = PlayerDoc.SelectSingleNode("PlayerConfig");
  18. }
  19. return _PlayerNode;
  20. }
  21. set { _PlayerNode = value; }
  22. }
  23. public static XmlDocument PlayerDoc
  24. {
  25. get
  26. {
  27. if (_PlayerDoc == null)
  28. {
  29. int version = 0;
  30. int nativeVersion = 0;
  31. XmlNode temoNode;
  32. XmlDocument tempDoc1;
  33. XmlDocument tempDoc2;
  34. FileInfo fileInfo = new FileInfo(Application.persistentDataPath + "/PlayerConfig.xml");
  35. if (fileInfo.Exists)
  36. {
  37. string path = Application.persistentDataPath + "/ICON2.png";
  38. if (!File.Exists(path))
  39. {
  40. Texture2D texture2D = ManaReso.Load<Texture2D>("ICON2", Folder.UI);
  41. File.WriteAllBytes(path, texture2D.EncodeToPNG());
  42. }
  43. StreamReader sr = new StreamReader(Application.persistentDataPath + "/PlayerConfig.xml");
  44. tempDoc1 = new XmlDocument();
  45. tempDoc1.LoadXml(sr.ReadToEnd());
  46. sr.Close();
  47. TextAsset textAsset = Bundle.Config.LoadAsset<TextAsset>("PlayerConfig");
  48. tempDoc2 = new XmlDocument();
  49. tempDoc2.LoadXml(textAsset.text);
  50. version = int.Parse(tempDoc2.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  51. temoNode = tempDoc1.SelectSingleNode("PlayerConfig").SelectSingleNode("Version");
  52. if (temoNode == null)
  53. {
  54. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  55. sw.Write(tempDoc2.OuterXml);
  56. sw.Close();
  57. _PlayerDoc = tempDoc2;
  58. }
  59. else
  60. {
  61. nativeVersion = int.Parse(temoNode.Attributes[0].Value);
  62. if (nativeVersion != version)
  63. {
  64. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  65. sw.Write(tempDoc2.OuterXml);
  66. sw.Close();
  67. _PlayerDoc = tempDoc2;
  68. }
  69. else
  70. {
  71. _PlayerDoc = tempDoc1;
  72. }
  73. }
  74. }
  75. else
  76. {
  77. TextAsset textAsset = Bundle.Config.LoadAsset<TextAsset>("PlayerConfig");
  78. tempDoc2 = new XmlDocument();
  79. tempDoc2.LoadXml(textAsset.text);
  80. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  81. sw.Write(tempDoc2.OuterXml);
  82. sw.Close();
  83. _PlayerDoc = tempDoc2;
  84. _PlayerDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  85. }
  86. }
  87. return _PlayerDoc;
  88. }
  89. set { _PlayerDoc = value; }
  90. }
  91. public static XmlNode _PlayerNode;
  92. public static XmlDocument _PlayerDoc;
  93. #endregion
  94. public static void SaveXml()
  95. {
  96. if (Initializer.LoadComplete)
  97. {
  98. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  99. sw.Write(PlayerDoc.OuterXml);
  100. sw.Close();
  101. }
  102. }
  103. public static void SaveSkillList()
  104. {
  105. if (ManaTutorial.TutorialA || !ManaData.InitiateComplete)
  106. {
  107. return;
  108. }
  109. XmlNode xmlNode;
  110. XmlAttribute xmlAttribute;
  111. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  112. xmlNode.RemoveAll();
  113. for (int i = 0; i < ManaData.SkillList.Count; i++)
  114. {
  115. if (ManaData.SkillList[i].SkillType == SkillType.Skill)
  116. {
  117. #region Skill
  118. Skill skill = (Skill)ManaData.SkillList[i];
  119. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  120. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  121. xmlAttribute.Value = skill.ID.ToString();
  122. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  123. xmlAttribute.Value = skill.SkillType.ToString();
  124. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  125. xmlAttribute.Value = skill.ItemStatus.ToString();
  126. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  127. xmlAttribute.Value = skill.Level.ToString();
  128. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  129. xmlAttribute.Value = skill.CoolTimer.ToString();
  130. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  131. xmlAttribute.Value = skill.UseTimer.ToString();
  132. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  133. #endregion
  134. }
  135. else if (ManaData.SkillList[i].SkillType == SkillType.Pack)
  136. {
  137. #region Pack
  138. Pack pack = (Pack)ManaData.SkillList[i];
  139. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  140. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  141. xmlAttribute.Value = pack.ID.ToString();
  142. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  143. xmlAttribute.Value = pack.SkillType.ToString();
  144. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  145. xmlAttribute.Value = pack.ItemStatus.ToString();
  146. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  147. xmlAttribute.Value = pack.Level.ToString();
  148. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  149. #endregion
  150. }
  151. else if (ManaData.SkillList[i].SkillType == SkillType.Ability)
  152. {
  153. #region Ability
  154. Ability ability = (Ability)ManaData.SkillList[i];
  155. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  156. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  157. xmlAttribute.Value = ability.ID.ToString();
  158. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  159. xmlAttribute.Value = ability.SkillType.ToString();
  160. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  161. xmlAttribute.Value = ability.ItemStatus.ToString();
  162. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  163. xmlAttribute.Value = ability.Level.ToString();
  164. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  165. #endregion
  166. }
  167. else if (ManaData.SkillList[i].SkillType == SkillType.BigSkill)
  168. {
  169. #region BigSkill
  170. BigSkill bigSkill = (BigSkill)ManaData.SkillList[i];
  171. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  172. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  173. xmlAttribute.Value = bigSkill.ID.ToString();
  174. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  175. xmlAttribute.Value = bigSkill.SkillType.ToString();
  176. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  177. xmlAttribute.Value = bigSkill.ItemStatus.ToString();
  178. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  179. xmlAttribute.Value = bigSkill.BarStatus.ToString();
  180. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  181. xmlAttribute.Value = bigSkill.Level.ToString();
  182. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  183. xmlAttribute.Value = bigSkill.CoolTimer.ToString();
  184. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  185. xmlAttribute.Value = bigSkill.UseTimer.ToString();
  186. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  187. #endregion
  188. }
  189. }
  190. }
  191. public static void SaveAchieve()
  192. {
  193. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  194. xmlNode.Attributes[0].Value = "";
  195. foreach (var kv in ManaAchieve.AchieveDic)
  196. {
  197. if (!kv.Value.Available)
  198. {
  199. xmlNode.Attributes[0].Value += kv.Value.ID_ + " ";
  200. }
  201. }
  202. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  203. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = ManaData.AdAmt.ToString("0");
  204. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = ManaData.SkillAmt.ToString("0");
  205. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = ManaData.SignAmt.ToString("0");
  206. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = ManaData.ShareAmt.ToString("0");
  207. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = ManaData.ElfLevel.ToString("0");
  208. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = ManaData.MiniGameAmt.ToString("0");
  209. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = ManaData.FlowerCoin.ToString("0");
  210. PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value = ManaData.TotalPerson.ToString("0");
  211. }
  212. public static void SavePlantList()
  213. {
  214. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
  215. attribute[0].Value = "";
  216. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  217. {
  218. Slot slot = ManaGarden.PlantList[i];
  219. attribute[0].Value = slot.ID + "," + slot.Index;
  220. if (i < ManaGarden.PlantList.Count - 1)
  221. {
  222. attribute[0].Value += " ";
  223. }
  224. }
  225. }
  226. public static void SaveCommon()
  227. {
  228. if (!ManaTutorial.TutorialA)
  229. {
  230. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = ManaData.Level.ToString();
  231. }
  232. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
  233. PlayerNode.SelectSingleNode("SignRound").Attributes[0].Value = ManaSign.SignRound.ToString();
  234. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaData.Coin.ToString("0");
  235. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaData.Diamond.ToString();
  236. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = ManaServer.Time.ToString();
  237. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaData.MiniTimer.ToString();
  238. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaData.CircleTimer.ToString();
  239. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
  240. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = ManaPlayer.SelePlayer;
  241. PlayerNode.SelectSingleNode("Language").Attributes[0].Value = ManaLan.CurrentLan.ToString();
  242. PlayerNode.SelectSingleNode("ID").Attributes[0].Value = ManaServer.ID;
  243. PlayerNode.SelectSingleNode("SignTime").Attributes[0].Value = ManaSign.SignTime.ToString();
  244. if (ManaServer.Connect)
  245. {
  246. PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = "1";
  247. }
  248. else
  249. {
  250. PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = "0";
  251. }
  252. if (ManaTutorial.TutorialA)
  253. {
  254. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = "1";
  255. }
  256. else
  257. {
  258. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = "0";
  259. }
  260. if (ManaTutorial.TutorialB_)
  261. {
  262. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = "1";
  263. }
  264. else
  265. {
  266. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = "0";
  267. }
  268. if (ManaTutorial.TutorialC_)
  269. {
  270. PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = "1";
  271. }
  272. else
  273. {
  274. PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = "0";
  275. }
  276. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = ManaTutorial.TutorialIndexA.ToString();
  277. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = ManaTutorial.TutorialIndexB.ToString();
  278. PlayerNode.SelectSingleNode("TutorialIndexC").Attributes[0].Value = ManaTutorial.TutorialIndexC.ToString();
  279. }
  280. public static void SaveFlowerList()
  281. {
  282. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  283. attribute.Value = "";
  284. foreach (var kv in ManaGarden.FlowerInfoDic)
  285. {
  286. if (kv.Value.Unlock)
  287. {
  288. attribute.Value += kv.Value.ID_ + " ";
  289. }
  290. }
  291. attribute.Value = attribute.Value.Trim(' ');
  292. }
  293. public static void SavePlayerConfig()
  294. {
  295. ManaVisit.DataReverse();
  296. SaveSkillList();
  297. SaveAchieve();
  298. SavePlantList();
  299. SaveCommon();
  300. SaveFlowerList();
  301. }
  302. public static void ResetSkillList()
  303. {
  304. XmlNode xmlNode;
  305. XmlAttribute xmlAttribute;
  306. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  307. xmlNode.RemoveAll();
  308. for (int i = 0; i < ManaData.SkillList.Count; i++)
  309. {
  310. if (ManaData.SkillList[i].SkillType == SkillType.Skill)
  311. {
  312. #region Skill
  313. Skill skill = (Skill)ManaData.SkillList[i];
  314. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  315. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  316. xmlAttribute.Value = skill.ID.ToString();
  317. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  318. xmlAttribute.Value = skill.SkillType.ToString();
  319. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  320. xmlAttribute.Value = SkillStatus.Lock.ToString();
  321. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  322. xmlAttribute.Value = 0.ToString();
  323. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  324. xmlAttribute.Value = 0.ToString();
  325. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  326. xmlAttribute.Value = 0.ToString();
  327. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  328. #endregion
  329. }
  330. else if (ManaData.SkillList[i].SkillType == SkillType.Pack)
  331. {
  332. #region Pack
  333. Pack pack = (Pack)ManaData.SkillList[i];
  334. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  335. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  336. xmlAttribute.Value = pack.ID.ToString();
  337. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  338. xmlAttribute.Value = pack.SkillType.ToString();
  339. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  340. xmlAttribute.Value = SkillStatus.Lock.ToString();
  341. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  342. xmlAttribute.Value = 0.ToString();
  343. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  344. #endregion
  345. }
  346. else if (ManaData.SkillList[i].SkillType == SkillType.Ability)
  347. {
  348. #region Ability
  349. Ability ability = (Ability)ManaData.SkillList[i];
  350. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  351. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  352. xmlAttribute.Value = ability.ID.ToString();
  353. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  354. xmlAttribute.Value = ability.SkillType.ToString();
  355. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  356. xmlAttribute.Value = SkillStatus.Lock.ToString();
  357. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  358. xmlAttribute.Value = 0.ToString();
  359. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  360. #endregion
  361. }
  362. else if (ManaData.SkillList[i].SkillType == SkillType.BigSkill)
  363. {
  364. #region BigSkill
  365. BigSkill bigSkill = (BigSkill)ManaData.SkillList[i];
  366. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  367. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  368. xmlAttribute.Value = bigSkill.ID.ToString();
  369. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  370. xmlAttribute.Value = bigSkill.SkillType.ToString();
  371. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  372. xmlAttribute.Value = SkillStatus.Lock.ToString();
  373. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  374. xmlAttribute.Value = SkillStatus.UnLock.ToString();
  375. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  376. xmlAttribute.Value = 0.ToString();
  377. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  378. xmlAttribute.Value = 0.ToString();
  379. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  380. xmlAttribute.Value = 0.ToString();
  381. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  382. #endregion
  383. }
  384. }
  385. }
  386. public static void ResetAchieve()
  387. {
  388. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  389. xmlNode.Attributes[0].Value = "";
  390. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = "0";
  391. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = "0";
  392. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = "0";
  393. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = "0";
  394. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = "0";
  395. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = "0";
  396. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = "0";
  397. PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value = "0";
  398. }
  399. public static void ResetPlantList()
  400. {
  401. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  402. xmlNode.Attributes[0].Value = "";
  403. }
  404. public static void ResetCommon()
  405. {
  406. PlayerNode.SelectSingleNode("Slot").Attributes[0].Value = "1";
  407. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = "1";
  408. PlayerNode.SelectSingleNode("SignRound").Attributes[0].Value = "1";
  409. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = "0";
  410. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = "0";
  411. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = "0";
  412. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  413. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = "0";
  414. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = "10";
  415. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = "0";
  416. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = "PlayerBlond";
  417. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = "1";
  418. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = "1";
  419. PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = "1";
  420. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = "1";
  421. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = "1";
  422. PlayerNode.SelectSingleNode("TutorialIndexC").Attributes[0].Value = "1";
  423. PlayerNode.SelectSingleNode("ID").Attributes[0].Value = "Default";
  424. PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = "1";
  425. PlayerNode.SelectSingleNode("SignTime").Attributes[0].Value = "4/22/2017 09:30:00 AM";
  426. PlayerNode.SelectSingleNode("Language").Attributes[0].Value = "ChineseSimplified";
  427. }
  428. public static void ResetFlowerList()
  429. {
  430. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  431. attribute.Value = "1";
  432. }
  433. public static void ResetPlayerConfig()
  434. {
  435. ResetSkillList();
  436. ResetAchieve();
  437. ResetPlantList();
  438. ResetCommon();
  439. ResetFlowerList();
  440. ManaData.Reset = true;
  441. }
  442. public static int GetPlayerInt(string node)
  443. {
  444. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  445. }
  446. public static bool GetPlayerBool(string node)
  447. {
  448. return Convert.ToBoolean(int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value));
  449. }
  450. public static float GetPlayerFloat(string node)
  451. {
  452. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  453. }
  454. public static string GetPlayerString(string node)
  455. {
  456. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  457. }
  458. public static double GetPlayerDouble(string node)
  459. {
  460. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  461. }
  462. public static void SavePlayerInt(string node, int value)
  463. {
  464. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  465. }
  466. public static void SavePlayerBool(string node, bool value)
  467. {
  468. string str;
  469. if (value)
  470. {
  471. str = "1";
  472. }
  473. else
  474. {
  475. str = "0";
  476. }
  477. PlayerNode.SelectSingleNode(node).Attributes[0].Value = str;
  478. SaveXml();
  479. }
  480. public static void SavePlayerFloat(string node, float value)
  481. {
  482. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  483. }
  484. public static void SavePlayerString(string node, string value)
  485. {
  486. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  487. }
  488. public static void SavePlayerDouble(string node, double value)
  489. {
  490. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  491. }
  492. public static List<int> GetFlowerList()
  493. {
  494. List<int> list = new List<int>();
  495. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  496. if (!string.IsNullOrEmpty(attribute[0].Value))
  497. {
  498. string[] strings = attribute[0].Value.Split(' ');
  499. for (int i = 0; i < strings.Length; i++)
  500. {
  501. list.Add(int.Parse(strings[i]));
  502. }
  503. }
  504. return list;
  505. }
  506. public static List<int> GetAchieveList()
  507. {
  508. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  509. }
  510. public static List<string> GetOfflineConfig()
  511. {
  512. TextAsset textAsset;
  513. XmlDocument xmlDoc = new XmlDocument();
  514. textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
  515. xmlDoc.LoadXml(textAsset.text);
  516. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  517. List<string> strList = new List<string>()
  518. {
  519. xmlNode.Attributes[1].Value,
  520. xmlNode.Attributes[2].Value,
  521. xmlNode.Attributes[3].Value,
  522. };
  523. return strList;
  524. }
  525. public static List<double> GetAchieveData()
  526. {
  527. List<double> dataList = new List<double>();
  528. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  529. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  530. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  531. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  532. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  533. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  534. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  535. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
  536. return dataList;
  537. }
  538. public static List<KV<int, int>> GetPlantList(XmlNode node = null)
  539. {
  540. List<KV<int, int>> list = new List<KV<int, int>>();
  541. XmlNode xmlNode;
  542. if (node == null)
  543. {
  544. xmlNode = PlayerNode.SelectSingleNode("PlantList");
  545. }
  546. else
  547. {
  548. xmlNode = node.SelectSingleNode("PlantList");
  549. }
  550. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  551. {
  552. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  553. for (int i = 0; i < strings.Length; i++)
  554. {
  555. list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
  556. }
  557. }
  558. return list;
  559. }
  560. public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
  561. {
  562. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  563. XmlNodeList xmlNodeList;
  564. if (node == null)
  565. {
  566. xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  567. }
  568. else
  569. {
  570. xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
  571. }
  572. for (int i = 0; i < xmlNodeList.Count; i++)
  573. {
  574. attributeList.Add(xmlNodeList[i].Attributes);
  575. }
  576. return attributeList;
  577. }
  578. public static XmlAttributeCollection GetVisitConfig()
  579. {
  580. TextAsset textAsset;
  581. XmlDocument xmlDoc = new XmlDocument();
  582. textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
  583. xmlDoc.LoadXml(textAsset.text);
  584. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  585. return xmlNode.Attributes;
  586. }
  587. public static XmlAttributeCollection GetAwardConfig()
  588. {
  589. TextAsset textAsset;
  590. XmlDocument xmlDoc = new XmlDocument();
  591. textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
  592. xmlDoc.LoadXml(textAsset.text);
  593. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  594. return xmlNode.Attributes;
  595. }
  596. public static List<XmlAttributeCollection> GetSkillConfig()
  597. {
  598. TextAsset textAsset;
  599. XmlDocument xmlDoc = new XmlDocument();
  600. List<XmlNodeList> xmlNodeLists = new List<XmlNodeList>();
  601. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  602. textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
  603. xmlDoc.LoadXml(textAsset.text);
  604. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  605. textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
  606. xmlDoc.LoadXml(textAsset.text);
  607. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  608. textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
  609. xmlDoc.LoadXml(textAsset.text);
  610. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  611. for (int i = 0; i < xmlNodeLists.Count; i++)
  612. {
  613. for (int j = 0; j < xmlNodeLists[i].Count; j++)
  614. {
  615. attributeList.Add(xmlNodeLists[i][j].Attributes);
  616. }
  617. }
  618. return attributeList;
  619. }
  620. public static List<XmlAttributeCollection> GetSignConfig()
  621. {
  622. TextAsset textAsset;
  623. XmlNodeList xmlNodeList;
  624. XmlDocument xmlDoc = new XmlDocument();
  625. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  626. textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
  627. xmlDoc.LoadXml(textAsset.text);
  628. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  629. for (int i = 0; i < xmlNodeList.Count; i++)
  630. {
  631. attributeList.Add(xmlNodeList[i].Attributes);
  632. }
  633. return attributeList;
  634. }
  635. public static List<XmlAttributeCollection> GetFlowerConfig()
  636. {
  637. TextAsset textAsset;
  638. XmlNodeList xmlNodeList;
  639. XmlDocument xmlDoc = new XmlDocument();
  640. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  641. textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
  642. xmlDoc.LoadXml(textAsset.text);
  643. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  644. for (int i = 0; i < xmlNodeList.Count; i++)
  645. {
  646. attributeList.Add(xmlNodeList[i].Attributes);
  647. }
  648. return attributeList;
  649. }
  650. public static List<XmlAttributeCollection> GetAchieveConfig()
  651. {
  652. TextAsset textAsset;
  653. XmlNodeList xmlNodeList;
  654. XmlDocument xmlDoc = new XmlDocument();
  655. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  656. textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
  657. xmlDoc.LoadXml(textAsset.text);
  658. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  659. for (int i = 0; i < xmlNodeList.Count; i++)
  660. {
  661. attributeList.Add(xmlNodeList[i].Attributes);
  662. }
  663. return attributeList;
  664. }
  665. }