Data.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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. StreamReader sr = new StreamReader(Application.persistentDataPath + "/PlayerConfig.xml");
  38. tempDoc1 = new XmlDocument();
  39. tempDoc1.LoadXml(sr.ReadToEnd());
  40. sr.Close();
  41. TextAsset textAsset = Bundle.Config.LoadAsset<TextAsset>("PlayerConfig");
  42. tempDoc2 = new XmlDocument();
  43. tempDoc2.LoadXml(textAsset.text);
  44. version = int.Parse(tempDoc2.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
  45. temoNode = tempDoc1.SelectSingleNode("PlayerConfig").SelectSingleNode("Version");
  46. if (temoNode == null)
  47. {
  48. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  49. sw.Write(tempDoc2.OuterXml);
  50. sw.Close();
  51. _PlayerDoc = tempDoc2;
  52. }
  53. else
  54. {
  55. nativeVersion = int.Parse(temoNode.Attributes[0].Value);
  56. if (nativeVersion != version)
  57. {
  58. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  59. sw.Write(tempDoc2.OuterXml);
  60. sw.Close();
  61. _PlayerDoc = tempDoc2;
  62. }
  63. else
  64. {
  65. _PlayerDoc = tempDoc1;
  66. }
  67. }
  68. }
  69. else
  70. {
  71. TextAsset textAsset = Bundle.Config.LoadAsset<TextAsset>("PlayerConfig");
  72. tempDoc2 = new XmlDocument();
  73. tempDoc2.LoadXml(textAsset.text);
  74. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  75. sw.Write(tempDoc2.OuterXml);
  76. sw.Close();
  77. _PlayerDoc = tempDoc2;
  78. _PlayerDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  79. }
  80. }
  81. return _PlayerDoc;
  82. }
  83. set { _PlayerDoc = value; }
  84. }
  85. private static XmlNode _PlayerNode;
  86. private static XmlDocument _PlayerDoc;
  87. #endregion
  88. public static void SaveXml()
  89. {
  90. StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
  91. sw.Write(PlayerDoc.OuterXml);
  92. sw.Close();
  93. }
  94. private static void SaveSkillList()
  95. {
  96. XmlNode xmlNode;
  97. XmlAttribute xmlAttribute;
  98. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  99. xmlNode.RemoveAll();
  100. for (int i = 0; i < ManaData.SkillList.Count; i++)
  101. {
  102. if (ManaData.SkillList[i].SkillType == SkillType.Skill)
  103. {
  104. #region Skill
  105. Skill skill = (Skill)ManaData.SkillList[i];
  106. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  107. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  108. xmlAttribute.Value = skill.ID.ToString();
  109. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  110. xmlAttribute.Value = skill.SkillType.ToString();
  111. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  112. xmlAttribute.Value = skill.ItemStatus.ToString();
  113. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  114. xmlAttribute.Value = skill.Level.ToString();
  115. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  116. xmlAttribute.Value = skill.CoolTimer.ToString();
  117. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  118. xmlAttribute.Value = skill.UseTimer.ToString();
  119. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  120. #endregion
  121. }
  122. else if (ManaData.SkillList[i].SkillType == SkillType.Pack)
  123. {
  124. #region Pack
  125. Pack pack = (Pack)ManaData.SkillList[i];
  126. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  127. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  128. xmlAttribute.Value = pack.ID.ToString();
  129. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  130. xmlAttribute.Value = pack.SkillType.ToString();
  131. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  132. xmlAttribute.Value = pack.ItemStatus.ToString();
  133. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  134. xmlAttribute.Value = pack.Level.ToString();
  135. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  136. #endregion
  137. }
  138. else if (ManaData.SkillList[i].SkillType == SkillType.Ability)
  139. {
  140. #region Ability
  141. Ability ability = (Ability)ManaData.SkillList[i];
  142. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  143. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  144. xmlAttribute.Value = ability.ID.ToString();
  145. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  146. xmlAttribute.Value = ability.SkillType.ToString();
  147. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  148. xmlAttribute.Value = ability.ItemStatus.ToString();
  149. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  150. xmlAttribute.Value = ability.Level.ToString();
  151. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  152. #endregion
  153. }
  154. else if (ManaData.SkillList[i].SkillType == SkillType.BigSkill)
  155. {
  156. #region BigSkill
  157. BigSkill bigSkill = (BigSkill)ManaData.SkillList[i];
  158. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  159. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  160. xmlAttribute.Value = bigSkill.ID.ToString();
  161. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  162. xmlAttribute.Value = bigSkill.SkillType.ToString();
  163. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  164. xmlAttribute.Value = bigSkill.ItemStatus.ToString();
  165. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  166. xmlAttribute.Value = bigSkill.BarStatus.ToString();
  167. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  168. xmlAttribute.Value = bigSkill.Level.ToString();
  169. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  170. xmlAttribute.Value = bigSkill.CoolTimer.ToString();
  171. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  172. xmlAttribute.Value = bigSkill.UseTimer.ToString();
  173. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  174. #endregion
  175. }
  176. }
  177. }
  178. private static void SaveAchieve()
  179. {
  180. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  181. xmlNode.Attributes[0].Value = "";
  182. foreach (var kv in ManaAchieve.AchieveDic)
  183. {
  184. if (!kv.Value.Available)
  185. {
  186. xmlNode.Attributes[0].Value += kv.Value.ID_ + " ";
  187. }
  188. }
  189. xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
  190. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = ManaData.AD.ToString("0");
  191. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = ManaData.Skill.ToString("0");
  192. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = ManaData.SignAmt.ToString("0");
  193. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = ManaData.Share.ToString("0");
  194. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = ManaData.MiniGameAmt.ToString("0");
  195. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = ManaData.FlowerCoin.ToString("0");
  196. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = ManaData.TotalPerson.ToString("0");
  197. }
  198. private static void SavePlantList()
  199. {
  200. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
  201. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  202. {
  203. Slot slot = ManaGarden.PlantList[i];
  204. attribute[0].Value = slot.ID + "," + slot.name;
  205. if (i < ManaGarden.PlantList.Count - 1)
  206. {
  207. attribute[0].Value += " ";
  208. }
  209. }
  210. }
  211. private static void SaveCommon()
  212. {
  213. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
  214. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaData.Coin.ToString("0");
  215. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = ManaData.Level.ToString();
  216. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaData.Diamond.ToString();
  217. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  218. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaData.MiniTimer.ToString();
  219. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaData.CircleTimer.ToString();
  220. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
  221. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = Tutorial.SelectPlayer;
  222. }
  223. private static void SaveFlowerList()
  224. {
  225. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  226. attribute.Value = "";
  227. foreach (var kv in ManaGarden.FlowerInfoDic)
  228. {
  229. if (kv.Value.Unlock)
  230. {
  231. attribute.Value += kv.Value.ID_ + " ";
  232. }
  233. }
  234. attribute.Value = attribute.Value.Trim(' ');
  235. }
  236. public static void SavePlayerConfig()
  237. {
  238. SaveSkillList();
  239. SaveAchieve();
  240. SavePlantList();
  241. SaveCommon();
  242. SaveFlowerList();
  243. SaveXml();
  244. }
  245. private static void ResetSkillList()
  246. {
  247. XmlNode xmlNode;
  248. XmlAttribute xmlAttribute;
  249. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  250. xmlNode.RemoveAll();
  251. for (int i = 0; i < ManaData.SkillList.Count; i++)
  252. {
  253. if (ManaData.SkillList[i].SkillType == SkillType.Skill)
  254. {
  255. #region Skill
  256. Skill skill = (Skill)ManaData.SkillList[i];
  257. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  258. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  259. xmlAttribute.Value = skill.ID.ToString();
  260. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  261. xmlAttribute.Value = skill.SkillType.ToString();
  262. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  263. xmlAttribute.Value = SkillStatus.Lock.ToString();
  264. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  265. xmlAttribute.Value = 0.ToString();
  266. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  267. xmlAttribute.Value = 0.ToString();
  268. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  269. xmlAttribute.Value = 0.ToString();
  270. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  271. #endregion
  272. }
  273. else if (ManaData.SkillList[i].SkillType == SkillType.Pack)
  274. {
  275. #region Pack
  276. Pack pack = (Pack)ManaData.SkillList[i];
  277. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  278. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  279. xmlAttribute.Value = pack.ID.ToString();
  280. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  281. xmlAttribute.Value = pack.SkillType.ToString();
  282. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  283. xmlAttribute.Value = SkillStatus.Lock.ToString();
  284. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  285. xmlAttribute.Value = 0.ToString();
  286. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  287. #endregion
  288. }
  289. else if (ManaData.SkillList[i].SkillType == SkillType.Ability)
  290. {
  291. #region Ability
  292. Ability ability = (Ability)ManaData.SkillList[i];
  293. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  294. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  295. xmlAttribute.Value = ability.ID.ToString();
  296. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  297. xmlAttribute.Value = ability.SkillType.ToString();
  298. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  299. xmlAttribute.Value = SkillStatus.Lock.ToString();
  300. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  301. xmlAttribute.Value = 0.ToString();
  302. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  303. #endregion
  304. }
  305. else if (ManaData.SkillList[i].SkillType == SkillType.BigSkill)
  306. {
  307. #region BigSkill
  308. BigSkill bigSkill = (BigSkill)ManaData.SkillList[i];
  309. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  310. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  311. xmlAttribute.Value = bigSkill.ID.ToString();
  312. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  313. xmlAttribute.Value = bigSkill.SkillType.ToString();
  314. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  315. xmlAttribute.Value = SkillStatus.Lock.ToString();
  316. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  317. xmlAttribute.Value = SkillStatus.Buy.ToString();
  318. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  319. xmlAttribute.Value = 0.ToString();
  320. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  321. xmlAttribute.Value = 0.ToString();
  322. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  323. xmlAttribute.Value = 0.ToString();
  324. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  325. #endregion
  326. }
  327. }
  328. }
  329. private static void ResetAchieve()
  330. {
  331. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  332. xmlNode.Attributes[0].Value = "";
  333. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = "0";
  334. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = "0";
  335. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = "0";
  336. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = "0";
  337. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = "0";
  338. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = "0";
  339. PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = "0";
  340. }
  341. private static void ResetPlantList()
  342. {
  343. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  344. xmlNode.Attributes[0].Value = "";
  345. }
  346. private static void ResetCommon()
  347. {
  348. PlayerNode.SelectSingleNode("Slot").Attributes[0].Value = "1";
  349. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = "1";
  350. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = "0";
  351. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = "0";
  352. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = "0";
  353. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  354. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = "0";
  355. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = "10";
  356. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = "0";
  357. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = "PlayerBlond";
  358. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = "0";
  359. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = "0";
  360. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = "1";
  361. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = "1";
  362. }
  363. private static void ResetFlowerList()
  364. {
  365. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  366. attribute.Value = "1";
  367. }
  368. public static void ResetPlayerConfig()
  369. {
  370. ResetSkillList();
  371. ResetAchieve();
  372. ResetPlantList();
  373. ResetCommon();
  374. ResetFlowerList();
  375. SaveXml();
  376. }
  377. public static int GetPlayerInt(string node)
  378. {
  379. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  380. }
  381. public static bool GetPlayerBool(string node)
  382. {
  383. return Convert.ToBoolean(int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value));
  384. }
  385. public static float GetPlayerFloat(string node)
  386. {
  387. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  388. }
  389. public static string GetPlayerString(string node)
  390. {
  391. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  392. }
  393. public static double GetPlayerDouble(string node)
  394. {
  395. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  396. }
  397. public static void SavePlayerInt(string node, int value)
  398. {
  399. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  400. SaveXml();
  401. }
  402. public static void SavePlayerBool(string node, bool value)
  403. {
  404. string str;
  405. if (value)
  406. {
  407. str = "1";
  408. }
  409. else
  410. {
  411. str = "0";
  412. }
  413. PlayerNode.SelectSingleNode(node).Attributes[0].Value = str;
  414. SaveXml();
  415. }
  416. public static void SavePlayerFloat(string node, float value)
  417. {
  418. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  419. SaveXml();
  420. }
  421. public static void SavePlayerString(string node, string value)
  422. {
  423. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  424. SaveXml();
  425. }
  426. public static void SavePlayerDouble(string node, double value)
  427. {
  428. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  429. SaveXml();
  430. }
  431. public static List<int> GetFlowerList()
  432. {
  433. List<int> list = new List<int>();
  434. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  435. if (!string.IsNullOrEmpty(attribute[0].Value))
  436. {
  437. string[] strings = attribute[0].Value.Split(' ');
  438. for (int i = 0; i < strings.Length; i++)
  439. {
  440. list.Add(int.Parse(strings[i]));
  441. }
  442. }
  443. return list;
  444. }
  445. public static List<int> GetAchieveList()
  446. {
  447. return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
  448. }
  449. public static List<double> GetAchieveData()
  450. {
  451. List<double> dataList = new List<double>();
  452. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  453. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  454. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  455. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  456. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  457. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  458. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
  459. return dataList;
  460. }
  461. public static List<KV<int, string>> GetPlantList()
  462. {
  463. List<KV<int, string>> list = new List<KV<int, string>>();
  464. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  465. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  466. {
  467. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  468. for (int i = 0; i < strings.Length; i++)
  469. {
  470. list.Add(new KV<int, string>(int.Parse(strings[i].Split(',')[0]), strings[i].Split(',')[1]));
  471. }
  472. }
  473. return list;
  474. }
  475. public static List<XmlAttributeCollection> GetSkillList()
  476. {
  477. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  478. XmlNodeList xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  479. for (int i = 0; i < xmlNodeList.Count; i++)
  480. {
  481. attributeList.Add(xmlNodeList[i].Attributes);
  482. }
  483. return attributeList;
  484. }
  485. public static XmlAttributeCollection GetAwardConfig()
  486. {
  487. TextAsset textAsset;
  488. XmlDocument xmlDoc = new XmlDocument();
  489. textAsset = Bundle.Config.LoadAsset<TextAsset>("award_config");
  490. xmlDoc.LoadXml(textAsset.text);
  491. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  492. return xmlNode.Attributes;
  493. }
  494. public static List<XmlAttributeCollection> GetSkillConfig()
  495. {
  496. TextAsset textAsset;
  497. XmlDocument xmlDoc = new XmlDocument();
  498. List<XmlNodeList> xmlNodeLists = new List<XmlNodeList>();
  499. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  500. textAsset = Bundle.Config.LoadAsset<TextAsset>("pack_config");
  501. xmlDoc.LoadXml(textAsset.text);
  502. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  503. textAsset = Bundle.Config.LoadAsset<TextAsset>("skill_config");
  504. xmlDoc.LoadXml(textAsset.text);
  505. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  506. textAsset = Bundle.Config.LoadAsset<TextAsset>("ability_config");
  507. xmlDoc.LoadXml(textAsset.text);
  508. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  509. for (int i = 0; i < xmlNodeLists.Count; i++)
  510. {
  511. for (int j = 0; j < xmlNodeLists[i].Count; j++)
  512. {
  513. attributeList.Add(xmlNodeLists[i][j].Attributes);
  514. }
  515. }
  516. return attributeList;
  517. }
  518. public static List<XmlAttributeCollection> GetSignConfig()
  519. {
  520. TextAsset textAsset;
  521. XmlNodeList xmlNodeList;
  522. XmlDocument xmlDoc = new XmlDocument();
  523. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  524. textAsset = Bundle.Config.LoadAsset<TextAsset>("signin_config");
  525. xmlDoc.LoadXml(textAsset.text);
  526. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  527. for (int i = 0; i < xmlNodeList.Count; i++)
  528. {
  529. attributeList.Add(xmlNodeList[i].Attributes);
  530. }
  531. return attributeList;
  532. }
  533. public static List<XmlAttributeCollection> GetFlowerConfig()
  534. {
  535. TextAsset textAsset;
  536. XmlNodeList xmlNodeList;
  537. XmlDocument xmlDoc = new XmlDocument();
  538. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  539. textAsset = Bundle.Config.LoadAsset<TextAsset>("flower_config");
  540. xmlDoc.LoadXml(textAsset.text);
  541. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  542. for (int i = 0; i < xmlNodeList.Count; i++)
  543. {
  544. attributeList.Add(xmlNodeList[i].Attributes);
  545. }
  546. return attributeList;
  547. }
  548. public static List<XmlAttributeCollection> GetAchieveConfig()
  549. {
  550. TextAsset textAsset;
  551. XmlNodeList xmlNodeList;
  552. XmlDocument xmlDoc = new XmlDocument();
  553. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  554. textAsset = Bundle.Config.LoadAsset<TextAsset>("achieve_config");
  555. xmlDoc.LoadXml(textAsset.text);
  556. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  557. for (int i = 0; i < xmlNodeList.Count; i++)
  558. {
  559. attributeList.Add(xmlNodeList[i].Attributes);
  560. }
  561. return attributeList;
  562. }
  563. }