Data.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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.FlowerInfoList.Count; i++)
  229. {
  230. if (ManaGarden.FlowerInfoList[i].Unlock)
  231. {
  232. attribute.Value += ManaGarden.FlowerInfoList[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("Tutorial").Attributes[0].Value = "1";
  361. PlayerNode.SelectSingleNode("TutorialIndex").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. List<int> list = new List<int>();
  448. XmlNode node = PlayerNode.SelectSingleNode("AchieveList");
  449. if (!string.IsNullOrEmpty(node.Attributes[0].Value))
  450. {
  451. string[] strings = node.Attributes[0].Value.Split(' ');
  452. for (int i = 0; i < strings.Length; i++)
  453. {
  454. list.Add(int.Parse(strings[i]));
  455. }
  456. }
  457. return list;
  458. }
  459. public static List<double> GetAchieveData()
  460. {
  461. List<double> dataList = new List<double>();
  462. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
  463. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
  464. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
  465. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
  466. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
  467. dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
  468. return dataList;
  469. }
  470. public static List<KV<int, string>> GetPlantList()
  471. {
  472. List<KV<int, string>> list = new List<KV<int, string>>();
  473. XmlNode xmlNode = PlayerNode.SelectSingleNode("PlantList");
  474. if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
  475. {
  476. string[] strings = xmlNode.Attributes[0].Value.Split(' ');
  477. for (int i = 0; i < strings.Length; i++)
  478. {
  479. list.Add(new KV<int, string>(int.Parse(strings[i].Split(',')[0]), strings[i].Split(',')[1]));
  480. }
  481. }
  482. return list;
  483. }
  484. public static List<XmlAttributeCollection> GetSkillList()
  485. {
  486. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  487. XmlNodeList xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
  488. for (int i = 0; i < xmlNodeList.Count; i++)
  489. {
  490. attributeList.Add(xmlNodeList[i].Attributes);
  491. }
  492. return attributeList;
  493. }
  494. public static XmlAttributeCollection GetAwardConfig()
  495. {
  496. TextAsset textAsset;
  497. XmlDocument xmlDoc = new XmlDocument();
  498. textAsset = Bundle.Config.LoadAsset<TextAsset>("award_config");
  499. xmlDoc.LoadXml(textAsset.text);
  500. XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
  501. return xmlNode.Attributes;
  502. }
  503. public static List<XmlAttributeCollection> GetSkillConfig()
  504. {
  505. TextAsset textAsset;
  506. XmlDocument xmlDoc = new XmlDocument();
  507. List<XmlNodeList> xmlNodeLists = new List<XmlNodeList>();
  508. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  509. textAsset = Bundle.Config.LoadAsset<TextAsset>("pack_config");
  510. xmlDoc.LoadXml(textAsset.text);
  511. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  512. textAsset = Bundle.Config.LoadAsset<TextAsset>("skill_config");
  513. xmlDoc.LoadXml(textAsset.text);
  514. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  515. textAsset = Bundle.Config.LoadAsset<TextAsset>("ability_config");
  516. xmlDoc.LoadXml(textAsset.text);
  517. xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
  518. for (int i = 0; i < xmlNodeLists.Count; i++)
  519. {
  520. for (int j = 0; j < xmlNodeLists[i].Count; j++)
  521. {
  522. attributeList.Add(xmlNodeLists[i][j].Attributes);
  523. }
  524. }
  525. return attributeList;
  526. }
  527. public static List<XmlAttributeCollection> GetSignConfig()
  528. {
  529. TextAsset textAsset;
  530. XmlNodeList xmlNodeList;
  531. XmlDocument xmlDoc = new XmlDocument();
  532. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  533. textAsset = Bundle.Config.LoadAsset<TextAsset>("signin_config");
  534. xmlDoc.LoadXml(textAsset.text);
  535. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  536. for (int i = 0; i < xmlNodeList.Count; i++)
  537. {
  538. attributeList.Add(xmlNodeList[i].Attributes);
  539. }
  540. return attributeList;
  541. }
  542. public static List<XmlAttributeCollection> GetFlowerConfig()
  543. {
  544. TextAsset textAsset;
  545. XmlNodeList xmlNodeList;
  546. XmlDocument xmlDoc = new XmlDocument();
  547. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  548. textAsset = Bundle.Config.LoadAsset<TextAsset>("flower_config");
  549. xmlDoc.LoadXml(textAsset.text);
  550. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  551. for (int i = 0; i < xmlNodeList.Count; i++)
  552. {
  553. attributeList.Add(xmlNodeList[i].Attributes);
  554. }
  555. return attributeList;
  556. }
  557. public static List<XmlAttributeCollection> GetAchieveConfig()
  558. {
  559. TextAsset textAsset;
  560. XmlNodeList xmlNodeList;
  561. XmlDocument xmlDoc = new XmlDocument();
  562. List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
  563. textAsset = Bundle.Config.LoadAsset<TextAsset>("achieve_config");
  564. xmlDoc.LoadXml(textAsset.text);
  565. xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
  566. for (int i = 0; i < xmlNodeList.Count; i++)
  567. {
  568. attributeList.Add(xmlNodeList[i].Attributes);
  569. }
  570. return attributeList;
  571. }
  572. }