|
@@ -4,45 +4,15 @@ using UnityEngine;
|
|
|
using System.Xml;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Text;
|
|
|
|
|
|
public class Data
|
|
|
{
|
|
|
#region
|
|
|
|
|
|
- public static XmlNode PlayerNode
|
|
|
- {
|
|
|
- get
|
|
|
- {
|
|
|
- if (_PlayerNode == null)
|
|
|
- {
|
|
|
- _PlayerNode = PlayerDoc.SelectSingleNode("PlayerConfig");
|
|
|
- }
|
|
|
-
|
|
|
- return _PlayerNode;
|
|
|
- }
|
|
|
- set { _PlayerNode = value; }
|
|
|
- }
|
|
|
- public static XmlDocument PlayerDoc
|
|
|
- {
|
|
|
- get
|
|
|
- {
|
|
|
- if (_PlayerDoc == null)
|
|
|
- {
|
|
|
- TextAsset textAsset = (TextAsset)Resources.Load(@"XML\Config\PlayerConfig");
|
|
|
-
|
|
|
- _PlayerDoc = new XmlDocument();
|
|
|
- _PlayerDoc.LoadXml(textAsset.text);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return _PlayerDoc;
|
|
|
- }
|
|
|
- set { _PlayerDoc = value; }
|
|
|
- }
|
|
|
-
|
|
|
- private static XmlNode _PlayerNode;
|
|
|
- private static XmlDocument _PlayerDoc;
|
|
|
+ public static XmlNode PlayerNode;
|
|
|
+ public static XmlDocument PlayerDoc;
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -158,8 +128,6 @@ public class Data
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void SavePlantList()
|
|
@@ -172,8 +140,6 @@ public class Data
|
|
|
attributes.Append(PlayerDoc.CreateAttribute(ManaGarden.PlantList[i].ParTra.name));
|
|
|
attributes[i].Value = ManaGarden.PlantList[i].Id.ToString();
|
|
|
}
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void SaveCommon()
|
|
@@ -186,8 +152,6 @@ public class Data
|
|
|
PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
|
|
|
PlayerNode.SelectSingleNode("CoinPerson").Attributes[0].Value = ManaData.CoinPerson.ToString();
|
|
|
PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaData.CircleTimer.ToString();
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void SaveFlowerList()
|
|
@@ -206,8 +170,6 @@ public class Data
|
|
|
}
|
|
|
|
|
|
xmlAttribute.Value = xmlAttribute.Value.Trim(' ');
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
public static void SavePlayerConfig()
|
|
@@ -216,6 +178,12 @@ public class Data
|
|
|
SavePlantList();
|
|
|
SaveCommon();
|
|
|
SaveFlowerList();
|
|
|
+
|
|
|
+ StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
+
|
|
|
+ sw.Write(PlayerDoc.OuterXml);
|
|
|
+
|
|
|
+ sw.Close();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -331,8 +299,6 @@ public class Data
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void ResetPlantList()
|
|
@@ -366,8 +332,6 @@ public class Data
|
|
|
|
|
|
xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("FlowerTraA9"));
|
|
|
xmlAttribute.Value = 9.ToString();
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void ResetCommon()
|
|
@@ -380,8 +344,6 @@ public class Data
|
|
|
PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = DateTime.Now.ToString();
|
|
|
PlayerNode.SelectSingleNode("CoinPerson").Attributes[0].Value = "1";
|
|
|
PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = "0";
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
private static void ResetFlowerList()
|
|
@@ -391,8 +353,6 @@ public class Data
|
|
|
|
|
|
XmlAttribute xmlAttribute = attributes.Append(PlayerDoc.CreateAttribute("ID"));
|
|
|
xmlAttribute.Value = "1 2 3 4 5 6 7 8 9 10";
|
|
|
-
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
}
|
|
|
|
|
|
public static void ResetPlayerConfig()
|
|
@@ -402,7 +362,11 @@ public class Data
|
|
|
ResetCommon();
|
|
|
ResetFlowerList();
|
|
|
|
|
|
- PlayerDoc.Save(Application.dataPath + @"\Resources\XML\Config\PlayerConfig.xml");
|
|
|
+ StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
|
|
|
+
|
|
|
+ sw.Write(PlayerDoc.OuterXml);
|
|
|
+
|
|
|
+ sw.Close();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -472,7 +436,7 @@ public class Data
|
|
|
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);
|
|
|
|