using UnityEngine; using UnityEngine.Events; using System.Collections; using System.Collections.Generic; using System.Xml; using LitJson; public class EquipManager { public UnityEvent InventoryUpdate; private Dictionary dataDict; private Dictionary equipedDict; private List inventoryList; private List hpList; private List dmgList; private List moveList; private bool m_Initialized; public bool initialized { get{ return m_Initialized; } } public EquipManager() { InventoryUpdate = new UnityEvent (); dataDict = new Dictionary(); InitByXML("XML/Config/All/equip_config"); equipedDict = new Dictionary (); inventoryList = new List (); hpList = new List (); dmgList = new List (); moveList = new List (); } 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{ if(success) { InitEquipInventory(data); } }); } private void InitEquipInventory(JsonData jsonArr) { inventoryList.Clear (); hpList.Clear (); dmgList.Clear (); moveList.Clear (); 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; } float ap = a.GetHpProperty () + a.GetDamageProperty (); float bp = b.GetHpProperty () + b.GetDamageProperty (); if (ap > bp) return -1; else if (ap < bp) return 1; return 0; } public List GetInventoryList() { return inventoryList; } private void InitEquiped() { equipedDict.Clear (); List list = CraftManager.GetInstance ().GetDataList (); for(int i=0; i list = CraftManager.GetInstance ().GetDataList (); for(int i=0; i rcmdDict) { for(int i=0; i rcmdDict) { for(int i=0; i rcmdDict) { for(int i=0; i