public DBDeck(XmlNode node, int _order) { //general stuff idName = node.Attributes ["idName"].Value; displayName = node ["name"].InnerXml; spriteName = node ["sprite"].InnerXml; sprite = Resources.Load <Sprite> (spriteName); order = _order; //deck deckListShortName = node ["deck"].InnerXml; deckListPath = Application.dataPath + "/external_data/player/decks/" + deckListShortName + ".txt"; cards = CardManager.instance.getDeckFromTextFile(deckListPath); for (int i = 0; i < cards.Count; i++) { cards [i].setup(null, null); } //charms XmlNodeList childNodes = node["charms"].ChildNodes; foreach (XmlNode n in childNodes) { if (n.Name == "charm") { string charmID = n.InnerXml; if (charmID.Length > 1) { Charm thisCharm = CharmManager.instance.getCharmFromIdName(charmID); thisCharm.setup(null, false, charmID); curCharm = thisCharm; } } } }
public Charm addCharm(string idName) { Charm thisCharm = CharmManager.instance.getCharmFromIdName(idName); charms.Add(thisCharm); thisCharm.setup(this, useGO, idName); if (isActive) { thisCharm.setActive(true); } return(thisCharm); }
public DBManager() { activeDeck = null; unusedCardsOpen = false; unusedWeaponsOpen = false; //grabbing the info for the player xmlPath = Application.dataPath + "/external_data/player/player_info.xml"; xmlDoc = new XmlDocument(); xmlDoc.Load(xmlPath); //get the info node XmlNode infoNode = xmlDoc.GetElementsByTagName("info")[0]; money = int.Parse(infoNode["money"].InnerXml); curLevel = int.Parse(infoNode ["cur_level"].InnerXml); //get the store node XmlNode storeNode = xmlDoc.GetElementsByTagName("store")[0]; storeIsAvailable = bool.Parse(storeNode ["unlocked"].InnerXml); //go through each unit and make a deck if it is player controlled XmlNodeList unitNodes = xmlDoc.GetElementsByTagName("unit"); foreach (XmlNode node in unitNodes) { if (bool.Parse(node ["currently_active"].InnerXml)) { DBDeck deck = new DBDeck(node, decks.Count); decks.Add(deck); //and make a button for it DBManagerInterface.instance.getDeckButtonGO().activate(deck); } } //make a special deck of unused cards unusedCardsDeck = new DBDeck(Application.dataPath + "/external_data/player/unused_cards.txt", decks.Count); decks.Add(unusedCardsDeck); DBManagerInterface.instance.getDeckButtonGO().activate(unusedCardsDeck); //gather up all of the unused charms unusedWeaponsListPath = Application.dataPath + "/external_data/player/unused_weapons.txt"; string charmText = File.ReadAllText(unusedWeaponsListPath); string[] charmLines = charmText.Split('\n'); for (int i = 0; i < charmLines.Length; i++) { if (charmLines [i].Length > 2) { Debug.Log("load " + charmLines [i]); Charm thisCharm = CharmManager.instance.getCharmFromIdName(charmLines [i]); thisCharm.setup(null, false, charmLines [i]); unusedCharms.Add(thisCharm); } } }