示例#1
0
        private void StartNode()
        {
            //Console.WriteLine("StartNode");

            var node = new TmxNode();

            // If we have a current node, this new node
            // will have it as its parent
            if (currentNode != null)
            {
                node.Parent = currentNode;
            }

            // If there is no root node, this new node is the root node
            if (rootNode == null)
            {
                rootNode    = node;
                currentNode = rootNode;
            }
            // If we already have a root node,
            else
            {
                if (currentNode.ChildNodes == null)
                {
                    currentNode.ChildNodes = new List <TmxNode>();
                }

                currentNode.ChildNodes.Add(node);
                currentNode = node;
            }

            nodeDepth++;
            nodeOpenBranceCount = 0;
        }
示例#2
0
        public TmxNode ParseTmx(string tmx)
        {
            tmxText  = tmx;
            rootNode = null;

            nodeDepth = 0;

            for (charIndex = 0; charIndex < tmx.Length; charIndex++)
            {
                switch (tmx[charIndex])
                {
                case '<':
                    StartNode();
                    break;

                case '>':
                    EndNode();
                    break;

                case '[':
                    StartAttribute();
                    break;

                case ']':
                    EndAttribute();
                    break;
                }
            }

            return(rootNode);
        }
示例#3
0
        private void EndNode()
        {
            //Console.WriteLine("EndNode");

            // Move up the hierarchy
            currentNode = currentNode.Parent;

            nodeDepth--;
        }
示例#4
0
        private static TmxNode ParseNode(XmlReader reader)
        {
            TmxNode result = null;

            switch (reader.Name)
            {
            case "tileset":
                result = ParseTileSetNode(reader);
                break;

            case "tileoffset":
                // TODO
                break;

            case "image":
                result = ParseImage(reader);
                break;

            case "terraintypes":
                // TODO
                break;

            case "terrain":
                // TODO
                break;

            case "tile":
                result = ParseTile(reader);
                break;

            case "animation":
                // TODO
                break;

            case "frame":
                // TODO
                break;

            case "layer":
                // TODO
                break;

            case "data":
                // TODO
                break;

            case "objectgroup":
                // TODO
                break;

            case "object":
                // TODO
                break;

            case "ellipse":
                // TODO
                break;

            case "polygon":
                // TODO
                break;

            case "polyline":
                // TODO
                break;

            case "imagelayer":
                // TODO
                break;

            case "properties":
                result = ParseProperties(reader);
                break;

            case "property":
                result = ParseProperty(reader);
                break;
            }

            return(result);
        }