Data.cs 28 KB

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