Data.cs 26 KB

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