Data.cs 30 KB

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