Danmaku_no_Kyojin.BulletEngine.BulletMLNode.FindLabelNode C# (CSharp) Method

FindLabelNode() public method

Find a node of a specific type and label Recurse into the xml tree until we find it!
public FindLabelNode ( string strLabel, ENodeName eName ) : BulletMLNode
strLabel string
eName ENodeName
return BulletMLNode
        public BulletMLNode FindLabelNode(string strLabel, ENodeName eName)
        {
            //this uses breadth first search, since labelled nodes are usually top level

            //Check if any of our child nodes match the request
            for (int i = 0; i < ChildNodes.Count; i++)
            {
                if ((eName == ChildNodes[i].Name) && (strLabel == ChildNodes[i].Label))
                {
                    return ChildNodes[i];
                }
            }

            //recurse into the child nodes and see if we find any matches
            for (int i = 0; i < ChildNodes.Count; i++)
            {
                BulletMLNode foundNode = ChildNodes[i].FindLabelNode(strLabel, eName);
                if (null != foundNode)
                {
                    return foundNode;
                }
            }

            //didnt find a BulletMLNode with that name :(
            return null;
        }

Usage Example

示例#1
0
        /// <summary>
        /// Initialize this bullet with a top level node
        /// </summary>
        /// <param name="rootNode">This is a top level node... find the first "top" node and use it to define this bullet</param>
        public void InitTop(BulletMLNode rootNode)
        {
            Debug.Assert(null != rootNode);

            //clear everything out
            _tasks.Clear();
            _fireData.Clear();
            _activeTaskNum = 0;

            //Grab that top level node
            MyNode = rootNode;

            //okay find the item labelled 'top'
            BulletMLNode topNode = rootNode.FindLabelNode("top", ENodeName.action);

            if (topNode != null)
            {
                //We found a top node, add a task for it, also add a firedata for the task
                BulletMLTask task = CreateTask();

                //parse the nodes into the task list
                task.Parse(topNode, this);
            }
            else
            {
                //ok there is no 'top' node, so that means we have a list of 'top#' nodes
                for (int i = 1; i < 10; i++)
                {
                    topNode = rootNode.FindLabelNode("top" + i, ENodeName.action);
                    if (topNode != null)
                    {
                        //found a top num node, add a task and firedata for it
                        BulletMLTask task = CreateTask();

                        //parse the nodes into the task list
                        task.Parse(topNode, this);
                    }
                }
            }
        }
All Usage Examples Of Danmaku_no_Kyojin.BulletEngine.BulletMLNode::FindLabelNode