|
@@ -4,24 +4,21 @@ using System.Xml;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
-public class Data : MonoBehaviour
|
|
|
+public class Data
|
|
|
{
|
|
|
- public static XmlNodeList GetFlowerConfig()
|
|
|
- {
|
|
|
- XmlDocument xmlDoc = new XmlDocument();
|
|
|
+ #region
|
|
|
|
|
|
- TextAsset textAsset = (TextAsset) Resources.Load(@"XML\Config\flower_config");
|
|
|
-
|
|
|
- xmlDoc.LoadXml(textAsset.text);
|
|
|
+ public static XmlNode PlayerConfig;
|
|
|
+ public static XmlDocument PlayerDoc;
|
|
|
|
|
|
- return xmlDoc.SelectSingleNode("data").SelectNodes("item");
|
|
|
- }
|
|
|
+ #endregion
|
|
|
|
|
|
- public static List<XmlNodeList> GetSkillConfig()
|
|
|
+ public static List<XmlAttributeCollection> GetSkillConfig()
|
|
|
{
|
|
|
TextAsset textAsset;
|
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
|
List<XmlNodeList> xmlNodeLists = new List<XmlNodeList>();
|
|
|
+ List<XmlAttributeCollection> attributesList = new List<XmlAttributeCollection>();
|
|
|
|
|
|
textAsset = (TextAsset)Resources.Load(@"XML\Config\pack_config");
|
|
|
xmlDoc.LoadXml(textAsset.text);
|
|
@@ -35,12 +32,180 @@ public class Data : MonoBehaviour
|
|
|
xmlDoc.LoadXml(textAsset.text);
|
|
|
xmlNodeLists.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
|
|
|
|
|
|
- return xmlNodeLists;
|
|
|
+ for (int i = 0; i < xmlNodeLists.Count; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ for (int j = 0; j < xmlNodeLists[i].Count; j++)
|
|
|
+ {
|
|
|
+ attributesList.Add(xmlNodeLists[i][j].Attributes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return attributesList;
|
|
|
}
|
|
|
|
|
|
+ public static List<XmlAttributeCollection> GetFlowerConfig()
|
|
|
+ {
|
|
|
+ XmlNodeList xmlNodeList;
|
|
|
+ XmlDocument xmlDoc = new XmlDocument();
|
|
|
+ List<XmlAttributeCollection> attributesList = new List<XmlAttributeCollection>();
|
|
|
+
|
|
|
+ TextAsset textAsset = (TextAsset) Resources.Load(@"XML\Config\flower_config");
|
|
|
+ xmlDoc.LoadXml(textAsset.text);
|
|
|
+
|
|
|
+ xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
|
|
|
+
|
|
|
+ for (int i = 0; i < xmlNodeList.Count; i++)
|
|
|
+ {
|
|
|
+ attributesList.Add(xmlNodeList[i].Attributes);
|
|
|
+ }
|
|
|
|
|
|
+ return attributesList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void SavePlayerConfig()
|
|
|
{
|
|
|
-
|
|
|
+ if (PlayerConfig == null)
|
|
|
+ {
|
|
|
+ TextAsset textAsset = (TextAsset)Resources.Load(@"XML\Config\PlayerConfig");
|
|
|
+
|
|
|
+ PlayerDoc = new XmlDocument();
|
|
|
+ PlayerDoc.LoadXml(textAsset.text);
|
|
|
+
|
|
|
+ PlayerConfig = PlayerDoc.SelectSingleNode("PlayerConfig");
|
|
|
+ }
|
|
|
+
|
|
|
+ XmlNode xmlNode;
|
|
|
+ XmlAttribute xmlAttribute;
|
|
|
+
|
|
|
+ PlayerConfig.SelectSingleNode("Coin").Attributes[0].Value = ManaData.Coin.ToString("0");
|
|
|
+ PlayerConfig.SelectSingleNode("Level").Attributes[0].Value = ManaData.Level.ToString();
|
|
|
+ PlayerConfig.SelectSingleNode("Person").Attributes[0].Value = ManaData.Person.ToString();
|
|
|
+ PlayerConfig.SelectSingleNode("Diamond").Attributes[0].Value = ManaData.Diamond.ToString();
|
|
|
+ PlayerConfig.SelectSingleNode("CoinPerson").Attributes[0].Value = ManaData.CoinPerson.ToString();
|
|
|
+
|
|
|
+ PlayerConfig.SelectSingleNode("QuitTime").Attributes[0].Value = System.DateTime.Now.ToString();
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Skill");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+ for (int i = 0; i < ManaData.SkillList.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, ManaData.SkillList[i].Name, ""));
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("status"));
|
|
|
+ xmlAttribute.Value = ManaData.SkillList[i].ItemSkillStatus.ToString();
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("level"));
|
|
|
+ xmlAttribute.Value = ManaData.SkillList[i].Level.ToString();
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Skill");
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("BigSkill");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+ for (int i = 0; i < ManaData.BigSkillList.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, ManaData.BigSkillList[i].Name, ""));
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("status"));
|
|
|
+ xmlAttribute.Value = ManaData.BigSkillList[i].ItemSkillStatus.ToString();
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("level"));
|
|
|
+ xmlAttribute.Value = ManaData.BigSkillList[i].Level.ToString();
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("BigSkill");
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Ability");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+ for (int i = 0; i < ManaData.AbilityList.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, ManaData.AbilityList[i].Name, ""));
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("status"));
|
|
|
+ xmlAttribute.Value = ManaData.AbilityList[i].ItemSkillStatus.ToString();
|
|
|
+
|
|
|
+ xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("level"));
|
|
|
+ xmlAttribute.Value = ManaData.AbilityList[i].Level.ToString();
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Ability");
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("CoolList");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+ for (int i = 0; i < ManaData.CoolList.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, ManaData.CoolList[i].Name, ""));
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("CoolList");
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("ProcessorList");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+ for (int i = 0; i < ManaData.ProcessorList.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, ManaData.ProcessorList[i].Name, ""));
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("ProcessorList");
|
|
|
+ }
|
|
|
+
|
|
|
+ PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void ResetPlayerConfig()
|
|
|
+ {
|
|
|
+ if (PlayerConfig == null)
|
|
|
+ {
|
|
|
+ TextAsset textAsset = (TextAsset)Resources.Load(@"XML\Config\PlayerConfig");
|
|
|
+
|
|
|
+ PlayerDoc = new XmlDocument();
|
|
|
+ PlayerDoc.LoadXml(textAsset.text);
|
|
|
+
|
|
|
+ PlayerConfig = PlayerDoc.SelectSingleNode("PlayerConfig");
|
|
|
+ }
|
|
|
+
|
|
|
+ XmlNode xmlNode;
|
|
|
+ XmlAttribute xmlAttribute;
|
|
|
+
|
|
|
+ PlayerConfig.SelectSingleNode("Coin").Attributes[0].Value = "0";
|
|
|
+ PlayerConfig.SelectSingleNode("Level").Attributes[0].Value = "0";
|
|
|
+ PlayerConfig.SelectSingleNode("Person").Attributes[0].Value = "1";
|
|
|
+ PlayerConfig.SelectSingleNode("Diamond").Attributes[0].Value = "0";
|
|
|
+ PlayerConfig.SelectSingleNode("CoinPerson").Attributes[0].Value = "1";
|
|
|
+
|
|
|
+ PlayerConfig.SelectSingleNode("QuitTime").Attributes[0].Value = "";
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Skill");
|
|
|
+
|
|
|
+ for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode.ChildNodes[i].Attributes[0].Value = "Lock";
|
|
|
+ xmlNode.ChildNodes[i].Attributes[1].Value = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("BigSkill");
|
|
|
+
|
|
|
+ for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode.ChildNodes[i].Attributes[0].Value = "Lock";
|
|
|
+ xmlNode.ChildNodes[i].Attributes[1].Value = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("Ability");
|
|
|
+
|
|
|
+ for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
|
|
|
+ {
|
|
|
+ xmlNode.ChildNodes[i].Attributes[0].Value = "Lock";
|
|
|
+ xmlNode.ChildNodes[i].Attributes[1].Value = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("CoolList");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+
|
|
|
+ xmlNode = PlayerConfig.SelectSingleNode("ProcessorList");
|
|
|
+ xmlNode.RemoveAll();
|
|
|
+
|
|
|
+ PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
}
|