using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Xml; using LitJson; public class EquipManager { private Dictionary dataDict; private Dictionary equipedDict; private List inventoryList; public List hpList; public List dmgList; public List moveList; public EquipManager() { dataDict = new Dictionary(); InitByXML("XML/Config/All/equip_config"); equipedDict = new Dictionary (); inventoryList = new List (); hpList = new List (); dmgList = new List (); moveList = new List (); InitEquiped (); } public void InitByXML(string path) { TextAsset textAsset = (TextAsset)Resources.Load(path); XmlDocument xml = new XmlDocument(); xml.LoadXml(textAsset.text); XmlNode mapNode = xml.SelectSingleNode("data"); XmlNodeList nodeList = mapNode.SelectNodes("item"); for(int i=0; i b.GetHpProperty ()) return -1; else if (a.GetHpProperty () < b.GetHpProperty ()) return 1; return 0; } private static int DamageCompare(Equipment a, Equipment b) { if (a.GetDamageProperty () > b.GetDamageProperty ()) return -1; else if (a.GetDamageProperty () < b.GetDamageProperty ()) return 1; return 0; } private static int MoveCompare(Equipment a, Equipment b) { if (a.GetMoveProperty () > b.GetMoveProperty ()) return -1; else if (a.GetMoveProperty () < b.GetMoveProperty ()) return 1; return 0; } public EquipData GetData(int id) { EquipData data = null; dataDict.TryGetValue (id, out data); return data; } public List GetInventoryList() { return inventoryList; } private void InitEquiped() { List list = CraftManager.GetInstance ().GetDataList (); for(int i=0; i