Data.cs 29 KB

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