Data.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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.Valid == false)
  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. }
  197. private static void SavePlantList()
  198. {
  199. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
  200. for (int i = 0; i < ManaGarden.PlantList.Count; i++)
  201. {
  202. Slot slot = ManaGarden.PlantList[i];
  203. attribute[0].Value = slot.ID + "," + slot.name;
  204. if (i < ManaGarden.PlantList.Count - 1)
  205. {
  206. attribute[0].Value += " ";
  207. }
  208. }
  209. }
  210. private static void SaveCommon()
  211. {
  212. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
  213. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaData.Coin.ToString("0");
  214. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = ManaData.Level.ToString();
  215. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaData.Diamond.ToString();
  216. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  217. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaData.MiniTimer.ToString();
  218. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaData.CircleTimer.ToString();
  219. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
  220. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = Tutorial.SelectPlayer;
  221. }
  222. private static void SaveFlowerList()
  223. {
  224. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  225. attribute.Value = "";
  226. for (int i = 0; i < ManaGarden.FlowerInfoDic.Count; i++)
  227. {
  228. if (ManaGarden.FlowerInfoDic[i].Unlock)
  229. {
  230. attribute.Value += ManaGarden.FlowerInfoDic[i].ID + " ";
  231. }
  232. }
  233. attribute.Value = attribute.Value.Trim(' ');
  234. }
  235. public static void SavePlayerConfig()
  236. {
  237. SaveSkillList();
  238. SaveAchieve();
  239. SavePlantList();
  240. SaveCommon();
  241. SaveFlowerList();
  242. SaveXml();
  243. }
  244. private static void ResetSkillList()
  245. {
  246. XmlNode xmlNode;
  247. XmlAttribute xmlAttribute;
  248. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  249. xmlNode.RemoveAll();
  250. for (int i = 0; i < ManaData.SkillList.Count; i++)
  251. {
  252. if (ManaData.SkillList[i].SkillType == SkillType.Skill)
  253. {
  254. #region Skill
  255. Skill skill = (Skill)ManaData.SkillList[i];
  256. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  257. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  258. xmlAttribute.Value = skill.ID_.ToString();
  259. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  260. xmlAttribute.Value = skill.SkillType.ToString();
  261. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  262. xmlAttribute.Value = SkillStatus.Lock.ToString();
  263. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  264. xmlAttribute.Value = 0.ToString();
  265. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  266. xmlAttribute.Value = 0.ToString();
  267. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  268. xmlAttribute.Value = 0.ToString();
  269. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  270. #endregion
  271. }
  272. else if (ManaData.SkillList[i].SkillType == SkillType.Pack)
  273. {
  274. #region Pack
  275. Pack pack = (Pack)ManaData.SkillList[i];
  276. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  277. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  278. xmlAttribute.Value = pack.ID_.ToString();
  279. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  280. xmlAttribute.Value = pack.SkillType.ToString();
  281. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  282. xmlAttribute.Value = SkillStatus.Lock.ToString();
  283. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  284. xmlAttribute.Value = 0.ToString();
  285. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  286. #endregion
  287. }
  288. else if (ManaData.SkillList[i].SkillType == SkillType.Ability)
  289. {
  290. #region Ability
  291. Ability ability = (Ability)ManaData.SkillList[i];
  292. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  293. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  294. xmlAttribute.Value = ability.ID_.ToString();
  295. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  296. xmlAttribute.Value = ability.SkillType.ToString();
  297. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  298. xmlAttribute.Value = SkillStatus.Lock.ToString();
  299. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  300. xmlAttribute.Value = 0.ToString();
  301. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  302. #endregion
  303. }
  304. else if (ManaData.SkillList[i].SkillType == SkillType.BigSkill)
  305. {
  306. #region BigSkill
  307. BigSkill bigSkill = (BigSkill)ManaData.SkillList[i];
  308. xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
  309. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
  310. xmlAttribute.Value = bigSkill.ID_.ToString();
  311. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
  312. xmlAttribute.Value = bigSkill.SkillType.ToString();
  313. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
  314. xmlAttribute.Value = SkillStatus.Lock.ToString();
  315. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
  316. xmlAttribute.Value = SkillStatus.Buy.ToString();
  317. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
  318. xmlAttribute.Value = 0.ToString();
  319. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CdTimer"));
  320. xmlAttribute.Value = 0.ToString();
  321. xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("EffectTimer"));
  322. xmlAttribute.Value = 0.ToString();
  323. xmlNode = PlayerNode.SelectSingleNode("SkillList");
  324. #endregion
  325. }
  326. }
  327. }
  328. private static void ResetAchieve()
  329. {
  330. XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
  331. xmlNode.Attributes[0].Value = "";
  332. PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = "0";
  333. PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = "0";
  334. PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = "0";
  335. PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = "0";
  336. PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = "0";
  337. PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = "0";
  338. }
  339. private static void ResetPlantList()
  340. {
  341. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  342. xmlNode.Attributes[0].Value = "";
  343. }
  344. private static void ResetCommon()
  345. {
  346. PlayerNode.SelectSingleNode("Slot").Attributes[0].Value = "1";
  347. PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = "1";
  348. PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = "0";
  349. PlayerNode.SelectSingleNode("Level").Attributes[0].Value = "0";
  350. PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = "0";
  351. PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
  352. PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = "0";
  353. PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = "10";
  354. PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = "0";
  355. PlayerNode.SelectSingleNode("Player").Attributes[0].Value = "PlayerBlond";
  356. PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = "1";
  357. PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = "1";
  358. PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = "1";
  359. PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = "1";
  360. }
  361. private static void ResetFlowerList()
  362. {
  363. XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
  364. attribute.Value = "1";
  365. }
  366. public static void ResetPlayerConfig()
  367. {
  368. ResetSkillList();
  369. ResetAchieve();
  370. ResetPlantList();
  371. ResetCommon();
  372. ResetFlowerList();
  373. SaveXml();
  374. }
  375. public static int GetPlayerInt(string node)
  376. {
  377. return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  378. }
  379. public static bool GetPlayerBool(string node)
  380. {
  381. return Convert.ToBoolean(int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value));
  382. }
  383. public static float GetPlayerFloat(string node)
  384. {
  385. return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  386. }
  387. public static string GetPlayerString(string node)
  388. {
  389. return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
  390. }
  391. public static double GetPlayerDouble(string node)
  392. {
  393. return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
  394. }
  395. public static void SavePlayerInt(string node, int value)
  396. {
  397. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  398. SaveXml();
  399. }
  400. public static void SavePlayerBool(string node, bool value)
  401. {
  402. string str;
  403. if (value)
  404. {
  405. str = "1";
  406. }
  407. else
  408. {
  409. str = "0";
  410. }
  411. PlayerNode.SelectSingleNode(node).Attributes[0].Value = str;
  412. SaveXml();
  413. }
  414. public static void SavePlayerFloat(string node, float value)
  415. {
  416. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  417. SaveXml();
  418. }
  419. public static void SavePlayerString(string node, string value)
  420. {
  421. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
  422. SaveXml();
  423. }
  424. public static void SavePlayerDouble(string node, double value)
  425. {
  426. PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
  427. SaveXml();
  428. }
  429. public static List<int> GetFlowerList()
  430. {
  431. List<int> list = new List<int>();
  432. XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
  433. if (!string.IsNullOrEmpty(attribute[0].Value))
  434. {
  435. string[] strings = attribute[0].Value.Split(' ');
  436. for (int i = 0; i < strings.Length; i++)
  437. {
  438. list.Add(int.Parse(strings[i]));
  439. }
  440. }
  441. return list;
  442. }
  443. public static List<int> GetAchieveList()
  444. {
  445. List<int> list = new List<int>();
  446. XmlNode node = PlayerNode.SelectSingleNode("AchieveList");
  447. if (!string.IsNullOrEmpty(node.Attributes[0].Value))
  448. {
  449. string[] strings = node.Attributes[0].Value.Split(' ');
  450. for (int i = 0; i < strings.Length; i++)
  451. {
  452. list.Add(int.Parse(strings[i]));
  453. }
  454. }
  455. return list;
  456. }
  457. public static List<double> GetAchieveData()
  458. {
  459. List<double> dataList = new List<double>();
  460. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  461. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  462. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  463. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  464. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  465. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  466. return dataList;
  467. }
  468. public static List<KV<int, string>> GetPlantList()
  469. {
  470. List<KV<int, string>> list = new List<KV<int, string>>();
  471. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  472. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  473. {
  474. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  475. for (int i = 0; i < strings.Length; i++)
  476. {
  477. list.Add(new KV<int, string>(int.Parse(strings[i].Split(',')[0]), strings[i].Split(',')[1]));
  478. }
  479. }
  480. return list;
  481. }
  482. public static List<XmlAttributeCollection> GetSkillList()
  483. {
  484. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  485. XmlNodeList xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  486. for (int i = 0; i < xmlNodeList.Count; i++)
  487. {
  488. attributeList.Add(xmlNodeList[i].Attributes);
  489. }
  490. return attributeList;
  491. }
  492. public static XmlAttributeCollection GetAwardConfig()
  493. {
  494. TextAsset textAsset;
  495. XmlDocument xmlDoc = new XmlDocument();
  496. textAsset = Bundle.Config.LoadAsset<TextAsset>("award_config");
  497. xmlDoc.LoadXml(textAsset.text);
  498. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  499. return xmlNode.Attributes;
  500. }
  501. public static List<XmlAttributeCollection> GetSkillConfig()
  502. {
  503. TextAsset textAsset;
  504. XmlDocument xmlDoc = new XmlDocument();
  505. List<XmlNodeList> xmlNodeLists = new List<XmlNodeList>();
  506. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  507. textAsset = Bundle.Config.LoadAsset<TextAsset>("pack_config");
  508. xmlDoc.LoadXml(textAsset.text);
  509. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  510. textAsset = Bundle.Config.LoadAsset<TextAsset>("skill_config");
  511. xmlDoc.LoadXml(textAsset.text);
  512. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  513. textAsset = Bundle.Config.LoadAsset<TextAsset>("ability_config");
  514. xmlDoc.LoadXml(textAsset.text);
  515. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  516. for (int i = 0; i < xmlNodeLists.Count; i++)
  517. {
  518. for (int j = 0; j < xmlNodeLists[i].Count; j++)
  519. {
  520. attributeList.Add(xmlNodeLists[i][j].Attributes);
  521. }
  522. }
  523. return attributeList;
  524. }
  525. public static List<XmlAttributeCollection> GetSignConfig()
  526. {
  527. TextAsset textAsset;
  528. XmlNodeList xmlNodeList;
  529. XmlDocument xmlDoc = new XmlDocument();
  530. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  531. textAsset = Bundle.Config.LoadAsset<TextAsset>("signin_config");
  532. xmlDoc.LoadXml(textAsset.text);
  533. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  534. for (int i = 0; i < xmlNodeList.Count; i++)
  535. {
  536. attributeList.Add(xmlNodeList[i].Attributes);
  537. }
  538. return attributeList;
  539. }
  540. public static List<XmlAttributeCollection> GetFlowerConfig()
  541. {
  542. TextAsset textAsset;
  543. XmlNodeList xmlNodeList;
  544. XmlDocument xmlDoc = new XmlDocument();
  545. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  546. textAsset = Bundle.Config.LoadAsset<TextAsset>("flower_config");
  547. xmlDoc.LoadXml(textAsset.text);
  548. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  549. for (int i = 0; i < xmlNodeList.Count; i++)
  550. {
  551. attributeList.Add(xmlNodeList[i].Attributes);
  552. }
  553. return attributeList;
  554. }
  555. public static List<XmlAttributeCollection> GetAchieveConfig()
  556. {
  557. TextAsset textAsset;
  558. XmlNodeList xmlNodeList;
  559. XmlDocument xmlDoc = new XmlDocument();
  560. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  561. textAsset = Bundle.Config.LoadAsset<TextAsset>("achieve_config");
  562. xmlDoc.LoadXml(textAsset.text);
  563. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  564. for (int i = 0; i < xmlNodeList.Count; i++)
  565. {
  566. attributeList.Add(xmlNodeList[i].Attributes);
  567. }
  568. return attributeList;
  569. }
  570. }