Data.cs 27 KB

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