12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118 |
- using LitJson;
- using UnityEngine;
- using System;
- using System.IO;
- using System.Xml;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using System.Security.Cryptography;
- using Random = UnityEngine.Random;
- public class ManaData : Regist
- {
- #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)
- {
- int defaultVersion;
- int nativeVersion;
- XmlNode node;
- XmlDocument nativeDoc = new XmlDocument();
- string configPath = Application.persistentDataPath + "/PlayerConfig.xml";
- if (File.Exists(configPath))
- {
- StreamReader sr = new StreamReader(configPath);
-
- nativeDoc.LoadXml(sr.ReadToEnd());
- sr.Close();
-
- Auxiliary.DecryptXml(nativeDoc);
-
- TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
- DefaultDoc.LoadXml(textAsset.text);
-
- defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
-
- node = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version");
- if (node == null)
- {
- StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
- sw.Write(DefaultDoc.OuterXml);
- sw.Close();
- PlayerDoc_ = DefaultDoc;
- }
- else
- {
- nativeVersion = int.Parse(node.Attributes[0].Value);
-
- if (nativeVersion < defaultVersion)
- {
- PlayerDoc_ = MergeXML(nativeVersion, nativeDoc, DefaultDoc);
- ManaServer.Save();
- }
- else if (nativeVersion > defaultVersion)
- {
- PlayerDoc_ = DefaultDoc;
- }
- else
- {
- byte[] bytes = Encoding.UTF8.GetBytes(nativeDoc.OuterXml);
- MD5 md5 = new MD5CryptoServiceProvider();
- if (PlayerPrefs.GetString("config") != Auxiliary.ToString(md5.ComputeHash(bytes)))
- {
- Debug.LogWarning("Download Archive");
- ManaDebug.Log("Download Archive");
- DamageLock = true;
- DownloadLock = false;
- return null;
- }
-
- PlayerDoc_ = nativeDoc;
- }
- }
- }
- else
- {
- TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
- DefaultDoc.LoadXml(textAsset.text);
- Debug.LogWarning("Download Archive");
- ManaDebug.Log("Download Archive");
- DamageLock = true;
- DownloadLock = false;
- return null;
- }
- }
- return PlayerDoc_;
- }
- set { PlayerDoc_ = value; }
- }
- public static XmlNode PlayerNode_;
- public static XmlDocument PlayerDoc_;
- public static float Timer;
- public static bool DamageLock;
- public static bool DownloadLock;
- public static XmlDocument DefaultDoc = new XmlDocument();
- #endregion
- public void Update()
- {
- if (DamageLock)
- {
- Timer += Time.deltaTime;
- if (Timer >= 10)
- {
- DamageLock = false;
- TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
- PlayerDoc_ = new XmlDocument();
- PlayerDoc_.LoadXml(textAsset.text);
- return;
- }
- }
- if (!DownloadLock)
- {
- if (ManaServer.ID != "Default")
- {
- DownloadLock = true;
- ManaServer.Download(ManaServer.ID, RecoveXml);
- }
- }
- }
- public override bool RegistImmed()
- {
- if (base.RegistImmed())
- {
- return true;
- }
- enabled = true;
- return false;
- }
- public static void SaveXml()
- {
- if (Initializer.Complete)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(PlayerDoc.OuterXml);
- MD5 md5 = new MD5CryptoServiceProvider();
- PlayerPrefs.SetString("id", ManaServer.ID);
- PlayerPrefs.SetString("config", Auxiliary.ToString(md5.ComputeHash(bytes)));
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(PlayerDoc.OuterXml);
-
- Auxiliary.EncryptXml(doc);
-
- StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/PlayerConfig.xml");
-
- sw.Write(doc.OuterXml);
- sw.Close();
- }
- }
- public static void RecoveXml(JsonData jsonData)
- {
- if (!DamageLock)
- {
- return;
- }
- DamageLock = false;
- TextAsset textAsset = ManaReso.Load<TextAsset>("PlayerConfig", Folder.Config);
- DefaultDoc.LoadXml(textAsset.text);
- if (jsonData.Inst_Object.Keys.Contains("l"))
- {
- PlayerDoc_ = new XmlDocument();
- PlayerDoc_.LoadXml(jsonData["l"].ToString());
- int nativeVersion = int.Parse(PlayerDoc_.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
- int defaultVersion = int.Parse(DefaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value);
- if (nativeVersion < defaultVersion)
- {
- MergeXML(nativeVersion, PlayerDoc_, DefaultDoc);
- ManaServer.Save();
- }
- else if (nativeVersion > defaultVersion)
- {
- PlayerDoc_ = DefaultDoc;
- }
- }
- else
- {
- PlayerDoc_ = DefaultDoc;
- }
- }
- public static void SaveSkillList()
- {
- if (ManaTutorial.TutorialA || !ManaCenter.Complete)
- {
- return;
- }
-
- XmlNode xmlNode;
- XmlAttribute xmlAttribute;
- xmlNode = PlayerNode.SelectSingleNode("SkillList");
- xmlNode.RemoveAll();
- for (int i = 0; i < ManaCenter.SkillList.Count; i++)
- {
- if (ManaCenter.SkillList[i].SkillType == SkillType.Skill)
- {
- #region Skill
- Skill skill = (Skill)ManaCenter.SkillList[i];
- xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
- xmlAttribute.Value = skill.ID;
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
- xmlAttribute.Value = skill.SkillType.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
- xmlAttribute.Value = skill.ItemStatus.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
- xmlAttribute.Value = skill.Level.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
- xmlAttribute.Value = skill.CoolTimer.ToString("0");
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
- xmlAttribute.Value = skill.UseTimer.ToString("0");
- xmlNode = PlayerNode.SelectSingleNode("SkillList");
- #endregion
- }
- else if (ManaCenter.SkillList[i].SkillType == SkillType.Pack)
- {
- #region Pack
- Pack pack = (Pack)ManaCenter.SkillList[i];
- xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
- xmlAttribute.Value = pack.ID;
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
- xmlAttribute.Value = pack.SkillType.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
- xmlAttribute.Value = pack.ItemStatus.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
- xmlAttribute.Value = pack.Level.ToString();
- xmlNode = PlayerNode.SelectSingleNode("SkillList");
- #endregion
- }
- else if (ManaCenter.SkillList[i].SkillType == SkillType.Ability)
- {
- #region Ability
- Ability ability = (Ability)ManaCenter.SkillList[i];
- xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
- xmlAttribute.Value = ability.ID;
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
- xmlAttribute.Value = ability.SkillType.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
- xmlAttribute.Value = ability.ItemStatus.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
- xmlAttribute.Value = ability.Level.ToString();
- xmlNode = PlayerNode.SelectSingleNode("SkillList");
- #endregion
- }
- else if (ManaCenter.SkillList[i].SkillType == SkillType.BigSkill)
- {
- #region BigSkill
- BigSkill bigSkill = (BigSkill)ManaCenter.SkillList[i];
- xmlNode = xmlNode.AppendChild(PlayerDoc.CreateNode(XmlNodeType.Element, "Skill", ""));
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ID"));
- xmlAttribute.Value = bigSkill.ID;
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("SkillType"));
- xmlAttribute.Value = bigSkill.SkillType.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("ItemStatus"));
- xmlAttribute.Value = bigSkill.ItemStatus.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("BarStatus"));
- xmlAttribute.Value = bigSkill.BarStatus.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("Level"));
- xmlAttribute.Value = bigSkill.Level.ToString();
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("CoolTimer"));
- xmlAttribute.Value = bigSkill.CoolTimer.ToString("0");
- xmlAttribute = xmlNode.Attributes.Append(PlayerDoc.CreateAttribute("UseTimer"));
- xmlAttribute.Value = bigSkill.UseTimer.ToString("0");
- xmlNode = PlayerNode.SelectSingleNode("SkillList");
- #endregion
- }
- }
- }
- public static void SaveDress()
- {
- XmlNode xmlNode = PlayerNode.SelectSingleNode("DressList");
- xmlNode.Attributes[0].Value = "";
- for (int i = 0; i < ManaPlayer.BoughtCloseList.Count; i++)
- {
- xmlNode.Attributes[0].Value += ManaPlayer.BoughtCloseList[i] + " ";
- }
- xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
- xmlNode = PlayerNode.SelectSingleNode("DressData");
- for (int i = 0; i < ManaPlayer.DressData.Count; i++)
- {
- xmlNode.Attributes[i].Value = ManaPlayer.DressData[i];
- }
- }
- public static void SaveAchieve()
- {
- XmlNode xmlNode = PlayerNode.SelectSingleNode("AchieveList");
- xmlNode.Attributes[0].Value = "";
- foreach (var kv in ManaAchieve.AchieveDic)
- {
- if (!kv.Value.Lock)
- {
- xmlNode.Attributes[0].Value += kv.Value.ID_ + " ";
- }
- }
- xmlNode.Attributes[0].Value = xmlNode.Attributes[0].Value.TrimEnd(' ');
- PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value = ManaCenter.AdAmt.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value = ManaCenter.SkillAmt.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value = ManaCenter.SignAmt.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value = ManaCenter.ShareAmt.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value = ManaCenter.ElfLevel.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value = ManaCenter.MiniGameAmt.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value = ManaCenter.FlowerCoin.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value = ManaCenter.TotalPerson.ToString("0");
- PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value = ManaCenter.CostDiamond.ToString("0");
- }
- public static void SavePlantList()
- {
- if (ManaVisit.InVisit || ManaTutorial.TutorialA)
- {
- return;
- }
-
- XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("PlantList").Attributes;
- attribute[0].Value = "";
- for (int i = 0; i < ManaGarden.PlantList.Count; i++)
- {
- Slot slot = ManaGarden.PlantList[i];
-
- attribute[0].Value += slot.ID + "," + slot.Index + " ";
- }
- attribute[0].Value = attribute[0].Value.TrimEnd(' ');
- }
- public static void SaveCommon()
- {
- PlayerNode.SelectSingleNode("Coin").Attributes[0].Value = ManaCenter.Coin.ToString("0");
- PlayerNode.SelectSingleNode("Diamond").Attributes[0].Value = ManaCenter.Diamond.ToString("0");
-
- PlayerNode.SelectSingleNode("SignTime").Attributes[0].Value = ManaSign.SignTime.ToString();
- PlayerNode.SelectSingleNode("SignIndex").Attributes[0].Value = ManaSign.SignIndex.ToString();
- PlayerNode.SelectSingleNode("SignRound").Attributes[0].Value = ManaSign.SignRound.ToString();
-
- PlayerNode.SelectSingleNode("QuitFlag").Attributes[0].Value = ManaServer.Connect.ToInt().ToString();
- PlayerNode.SelectSingleNode("QuitTime").Attributes[0].Value = ManaServer.Time.ToString();
- PlayerNode.SelectSingleNode("MiniTimer").Attributes[0].Value = ManaCenter.MiniTimer.ToString("0");
- PlayerNode.SelectSingleNode("CircleTimer").Attributes[0].Value = ManaCenter.CircleTimer.ToString("0");
- PlayerNode.SelectSingleNode("ID").Attributes[0].Value = ManaServer.ID;
- PlayerNode.SelectSingleNode("Language").Attributes[0].Value = ManaLan.CurrentLan.ToString();
- PlayerNode.SelectSingleNode("MiniGameIndex").Attributes[0].Value = ManaMiniGame.MiniGameIndex.ToString();
- PlayerNode.SelectSingleNode("TutorialA").Attributes[0].Value = ManaTutorial.TutorialA.ToInt().ToString();
- PlayerNode.SelectSingleNode("TutorialB").Attributes[0].Value = ManaTutorial.TutorialB_.ToInt().ToString();
- PlayerNode.SelectSingleNode("TutorialC").Attributes[0].Value = ManaTutorial.TutorialC_.ToInt().ToString();
- PlayerNode.SelectSingleNode("TutorialD").Attributes[0].Value = ManaTutorial.TutorialD_.ToInt().ToString();
- PlayerNode.SelectSingleNode("TutorialE").Attributes[0].Value = ManaTutorial.TutorialE_.ToInt().ToString();
- PlayerNode.SelectSingleNode("TutorialIndexA").Attributes[0].Value = ManaTutorial.TutorialIndexA.ToString();
- PlayerNode.SelectSingleNode("TutorialIndexB").Attributes[0].Value = ManaTutorial.TutorialIndexB.ToString();
- PlayerNode.SelectSingleNode("TutorialIndexC").Attributes[0].Value = ManaTutorial.TutorialIndexC.ToString();
- PlayerNode.SelectSingleNode("TutorialIndexD").Attributes[0].Value = ManaTutorial.TutorialIndexD.ToString();
- PlayerNode.SelectSingleNode("TutorialIndexE").Attributes[0].Value = ManaTutorial.TutorialIndexE.ToString();
- }
- public static void SaveFlowerList()
- {
- XmlAttribute attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes[0];
- attribute.Value = "";
- foreach (var kv in ManaGarden.FlowerInfoDic)
- {
- if (kv.Value.Unlock)
- {
- attribute.Value += kv.Value.ID_ + " ";
- }
- }
- attribute.Value = attribute.Value.Trim(' ');
- }
- public static void SavePlayerConfig()
- {
- if (Initializer.Complete)
- {
- SaveSkillList();
- SaveAchieve();
- SaveDress();
- SavePlantList();
- SaveCommon();
- SaveFlowerList();
- }
- }
- public static void ResetPlayerConfig()
- {
- PlayerPrefs.SetString("id", "");
- PlayerNode.SelectSingleNode("Version").Attributes[0].Value = "10000";
- SavePlayerConfig();
- ManaCenter.SaveLock = true;
- }
- public static int GetPlayerInt(string node)
- {
- return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
- }
- public static bool GetPlayerBool(string node)
- {
- return int.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value).ToBool();
- }
- public static float GetPlayerFloat(string node)
- {
- return float.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
- }
- public static string GetPlayerString(string node)
- {
- return PlayerNode.SelectSingleNode(node).Attributes[0].Value;
- }
- public static double GetPlayerDouble(string node)
- {
- return double.Parse(PlayerNode.SelectSingleNode(node).Attributes[0].Value);
- }
- public static void SavePlayerInt(string node, int value)
- {
- PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
- }
- public static void SavePlayerBool(string node, bool value)
- {
- PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToInt().ToString();
- }
- public static void SavePlayerFloat(string node, float value)
- {
- PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
- }
- public static void SavePlayerString(string node, string value)
- {
- PlayerNode.SelectSingleNode(node).Attributes[0].Value = value;
- }
- public static void SavePlayerDouble(string node, double value)
- {
- PlayerNode.SelectSingleNode(node).Attributes[0].Value = value.ToString();
- }
- public static List<int> GetDressList()
- {
- List<int> list = new List<int>();
- XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("DressList").Attributes;
- return Auxiliary.IntListParse(' ', attribute[0].Value, list);
- }
- public static List<string> GetDressData(XmlNode node = null)
- {
- XmlNode xmlNode;
- if (node == null)
- {
- xmlNode = PlayerNode.SelectSingleNode("DressData");
- }
- else
- {
- xmlNode = node.SelectSingleNode("DressData");
- }
- List<string> dataList = new List<string>();
- if (xmlNode != null && xmlNode.Attributes.Count == 8)
- {
- dataList.Add(xmlNode.Attributes[0].Value);
- dataList.Add(xmlNode.Attributes[1].Value);
- dataList.Add(xmlNode.Attributes[2].Value);
- dataList.Add(xmlNode.Attributes[3].Value);
- dataList.Add(xmlNode.Attributes[4].Value);
- dataList.Add(xmlNode.Attributes[5].Value);
- dataList.Add(xmlNode.Attributes[6].Value);
- dataList.Add(xmlNode.Attributes[7].Value);
- }
- else
- {
- float rate = Random.Range(0f, 1f);
- if (rate < 0.33f)
- {
- dataList.Add("脑壳1");
- dataList.Add("裙子1");
- dataList.Add("鞋子1");
- dataList.Add("头饰品1");
- dataList.Add("上衣1");
- dataList.Add("眼睛1");
- dataList.Add("嘴巴1");
- dataList.Add("Empty");
- }
- else if (rate < 0.66f)
- {
- dataList.Add("脑壳2");
- dataList.Add("裙子2");
- dataList.Add("鞋子2");
- dataList.Add("头饰品2");
- dataList.Add("上衣2");
- dataList.Add("眼睛2");
- dataList.Add("嘴巴2");
- dataList.Add("Empty");
- }
- else
- {
- dataList.Add("脑壳3");
- dataList.Add("裙子3");
- dataList.Add("鞋子3");
- dataList.Add("头饰品3");
- dataList.Add("上衣3");
- dataList.Add("眼睛3");
- dataList.Add("嘴巴3");
- dataList.Add("Empty");
- }
- }
- return dataList;
- }
- public static List<int> GetFlowerList()
- {
- List<int> list = new List<int>();
- XmlAttributeCollection attribute = PlayerNode.SelectSingleNode("FlowerList").Attributes;
- return Auxiliary.IntListParse(' ', attribute[0].Value, list);
- }
- public static List<int> GetAchieveList()
- {
- return Auxiliary.IntListParse(' ', GetPlayerString("AchieveList"), new List<int>());
- }
- public static List<string> GetOfflineConfig()
- {
- TextAsset textAsset = ManaReso.Load<TextAsset>("offline_config", Folder.Config);
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.LoadXml(textAsset.text);
- XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
- List<string> strList = new List<string>()
- {
- xmlNode.Attributes[1].Value,
- xmlNode.Attributes[2].Value,
- xmlNode.Attributes[3].Value,
- };
- return strList;
- }
- public static List<double> GetAchieveData()
- {
- List<double> dataList = new List<double>();
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[0].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[1].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[2].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[3].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[4].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[5].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[6].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[7].Value));
- dataList.Add(double.Parse(PlayerNode.SelectSingleNode("AchieveData").Attributes[8].Value));
- return dataList;
- }
- public static List<KV<int, int>> GetPlantList(XmlNode node = null)
- {
- List<KV<int, int>> list = new List<KV<int, int>>();
- XmlNode xmlNode;
- if (node == null)
- {
- xmlNode = PlayerNode.SelectSingleNode("PlantList");
- }
- else
- {
- xmlNode = node.SelectSingleNode("PlantList");
- }
- if (!string.IsNullOrEmpty(xmlNode.Attributes[0].Value))
- {
- string[] strings = xmlNode.Attributes[0].Value.Split(' ');
- for (int i = 0; i < strings.Length; i++)
- {
- list.Add(new KV<int, int>(int.Parse(strings[i].Split(',')[0]), int.Parse(strings[i].Split(',')[1])));
- }
- }
- return list;
- }
- public static List<XmlAttributeCollection> GetSkillList(XmlNode node = null)
- {
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
- XmlNodeList xmlNodeList;
- if (node == null)
- {
- xmlNodeList = PlayerNode.SelectSingleNode("SkillList").ChildNodes;
- }
- else
- {
- xmlNodeList = node.SelectSingleNode("SkillList").ChildNodes;
- }
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static XmlAttributeCollection GetVisitConfig()
- {
- TextAsset textAsset = ManaReso.Load<TextAsset>("visit_config", Folder.Config);
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.LoadXml(textAsset.text);
- XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
- return xmlNode.Attributes;
- }
- public static XmlAttributeCollection GetAwardConfig()
- {
- TextAsset textAsset = ManaReso.Load<TextAsset>("award_config", Folder.Config);
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.LoadXml(textAsset.text);
- XmlNode xmlNode = xmlDoc.SelectSingleNode("data").SelectSingleNode("item");
- return xmlNode.Attributes;
- }
- public static List<XmlAttributeCollection> GetIAPConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
- textAsset = ManaReso.Load<TextAsset>("iap_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetSkillConfig()
- {
- TextAsset textAsset;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlNodeList> xmlNodeList = new List<XmlNodeList>();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
-
- textAsset = ManaReso.Load<TextAsset>("pack_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
-
- textAsset = ManaReso.Load<TextAsset>("skill_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
-
- textAsset = ManaReso.Load<TextAsset>("ability_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList.Add(xmlDoc.SelectSingleNode("data").SelectNodes("item"));
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- for (int j = 0; j < xmlNodeList[i].Count; j++)
- {
- attributeList.Add(xmlNodeList[i][j].Attributes);
- }
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetSignConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
-
- textAsset = ManaReso.Load<TextAsset>("signin_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
-
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetFlowerConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
-
- textAsset = ManaReso.Load<TextAsset>("flower_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetLotteryConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
- textAsset = ManaReso.Load<TextAsset>("lottery_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetAchieveConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
- textAsset = ManaReso.Load<TextAsset>("achieve_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static List<XmlAttributeCollection> GetDressRoomConfig()
- {
- TextAsset textAsset;
- XmlNodeList xmlNodeList;
- XmlDocument xmlDoc = new XmlDocument();
- List<XmlAttributeCollection> attributeList = new List<XmlAttributeCollection>();
- textAsset = ManaReso.Load<TextAsset>("dressRoom_config", Folder.Config);
- xmlDoc.LoadXml(textAsset.text);
- xmlNodeList = xmlDoc.SelectSingleNode("data").SelectNodes("item");
- for (int i = 0; i < xmlNodeList.Count; i++)
- {
- attributeList.Add(xmlNodeList[i].Attributes);
- }
- return attributeList;
- }
- public static XmlDocument MergeXML(int nativeVersion, XmlDocument nativeDoc, XmlDocument defaultDoc)
- {
- if (nativeVersion < 681)
- {
- Debug.LogWarning("UpdateArchive");
- To681(nativeDoc, defaultDoc);
- }
- return nativeDoc;
- }
- public static XmlDocument To681(XmlDocument nativeDoc, XmlDocument defaultDoc)
- {
- string playerType = "";
- XmlNode xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressList");
- XmlNode xmlNode2 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
- XmlNode xmlNode3 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialD");
- XmlNode xmlNode4 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexD");
- XmlNode xmlNode5 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Player");
- XmlNode xmlNode6 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialE");
- XmlNode xmlNode7 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexE");
- XmlNode xmlNode8 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("AchieveData");
- if (xmlNode1 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode1);
- }
- if (xmlNode2 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode2);
- }
- if (xmlNode3 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode3);
- }
- if (xmlNode4 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode4);
- }
- if (xmlNode5 != null)
- {
- playerType = xmlNode5.Attributes[0].Value;
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode5);
- }
- else
- {
- playerType = "PlayerBlond";
- }
- if (xmlNode6 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode6);
- }
- if (xmlNode7 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode7);
- }
- if (xmlNode8 != null)
- {
- nativeDoc.SelectSingleNode("PlayerConfig").RemoveChild(xmlNode8);
- }
- nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Version").Attributes[0].Value = 681.ToString();
- xmlNode1 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressList");
- xmlNode2 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("DressData");
- xmlNode3 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialD");
- xmlNode4 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexD");
- xmlNode5 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("Player");
- xmlNode6 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialE");
- xmlNode7 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("TutorialIndexE");
- xmlNode8 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("AchieveData");
- if (playerType == "PlayerBlond")
- {
- xmlNode2.Attributes[0].Value = "脑壳1";
- xmlNode2.Attributes[1].Value = "裙子1";
- xmlNode2.Attributes[2].Value = "鞋子1";
- xmlNode2.Attributes[3].Value = "头饰品1";
- xmlNode2.Attributes[4].Value = "上衣1";
- xmlNode2.Attributes[5].Value = "眼睛1";
- xmlNode2.Attributes[6].Value = "嘴巴1";
- xmlNode2.Attributes[7].Value = "Empty";
- }
- else if (playerType == "PlayerBrown")
- {
- xmlNode2.Attributes[0].Value = "脑壳2";
- xmlNode2.Attributes[1].Value = "裙子2";
- xmlNode2.Attributes[2].Value = "鞋子2";
- xmlNode2.Attributes[3].Value = "头饰品2";
- xmlNode2.Attributes[4].Value = "上衣2";
- xmlNode2.Attributes[5].Value = "眼睛2";
- xmlNode2.Attributes[6].Value = "嘴巴2";
- xmlNode2.Attributes[7].Value = "Empty";
- }
- else if (playerType == "PlayerPink")
- {
- xmlNode2.Attributes[0].Value = "脑壳3";
- xmlNode2.Attributes[1].Value = "裙子3";
- xmlNode2.Attributes[2].Value = "鞋子3";
- xmlNode2.Attributes[3].Value = "头饰品3";
- xmlNode2.Attributes[4].Value = "上衣3";
- xmlNode2.Attributes[5].Value = "眼睛3";
- xmlNode2.Attributes[6].Value = "嘴巴3";
- xmlNode2.Attributes[7].Value = "Empty";
- }
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode1, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode2, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode3, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode4, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode5, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode6, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode7, true));
- nativeDoc.SelectSingleNode("PlayerConfig").AppendChild(nativeDoc.ImportNode(xmlNode8, true));
- xmlNode1 = nativeDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("SkillList");
- xmlNode2 = defaultDoc.SelectSingleNode("PlayerConfig").SelectSingleNode("SkillList");
- XmlNodeList xmlNodeList1 = xmlNode1.ChildNodes;
- XmlNodeList xmlNodeList2 = xmlNode2.ChildNodes;
- for (int i = 0; i < xmlNodeList1.Count; i++)
- {
- string id = xmlNodeList1[i].Attributes[0].Value;
- if (id.Contains("Ability"))
- {
- int index = int.Parse(id.Replace("Ability", ""));
- if (index >= 15 && index <= 24)
- {
- xmlNode1.RemoveChild(xmlNodeList1[i--]);
- }
- }
- }
-
- for (int i = 0; i < xmlNodeList2.Count; i++)
- {
- string id = xmlNodeList2[i].Attributes[0].Value;
- if (id.Contains("Ability"))
- {
- int index = int.Parse(id.Replace("Ability", ""));
- if (index >= 15 && index <= 24)
- {
- xmlNode1.AppendChild(nativeDoc.ImportNode(xmlNodeList2[i], true));
- }
- }
- }
-
- return nativeDoc;
- }
- }
|