// IEnumerator _LoadTreasureBoxConfig() // { // string strPath = ResourceLoadBase.GetResourceBasePath() + "Config/TreasureBox.xml"; // GuLog.Debug("TreasureBoxConfigPath" + strPath); // WWW www = new WWW(strPath); // yield return www; // // Parser(www); // // } public TreasureBox GetTreasureBoxById(int treasureBoxId) { TreasureBox ret = null; if (treasureBoxInfo.TryGetValue(treasureBoxId, out ret)) { return(ret); } return(ret); }
private void Parser(WWW www) { m_LoadOk = true; if (www.isDone && (www.error == null || www.error.Length == 0)) { SecurityParser xmlDoc = new SecurityParser(); xmlDoc.LoadXml(www.text); ArrayList worldXmlList = xmlDoc.ToXml().Children; foreach (SecurityElement xeTreasureBoxs in worldXmlList) { if (xeTreasureBoxs.Tag == "TreasureBoxes") { ArrayList TreasureBoxXmlList = xeTreasureBoxs.Children; foreach (SecurityElement xeTreasureBox in TreasureBoxXmlList) { if (xeTreasureBox.Tag == "TreasureBox") { TreasureBox tBox = new TreasureBox(); tBox.treasureBoxId = Convert.ToInt32(xeTreasureBox.Attribute("Id")); tBox.type = Convert.ToInt32(xeTreasureBox.Attribute("Type")); ArrayList TreasureXmlList = xeTreasureBox.Children; foreach (SecurityElement xeTreasure in TreasureXmlList) { if (xeTreasure.Tag == "Treasure") { Treasure TreasureInfo = new Treasure(); TreasureInfo.itemId = Convert.ToInt32(xeTreasure.Attribute("ItemId")); TreasureInfo.count = Convert.ToInt32(xeTreasure.Attribute("Value")); tBox.items.Add(TreasureInfo); } } treasureBoxInfo.Add(tBox.treasureBoxId, tBox); } } } } } }