예제 #1
0
        private static Pit LoadPit(XmlTextReader xml)
        {
            int x, y;
            Pit pit = null;

            x = Int32.Parse(xml.GetAttribute("x"));
            y = Int32.Parse(xml.GetAttribute("y"));

            pit = new Pit(x, y);

            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:

                    if (xml.Name.Equals("North"))
                    {
                        pit.setVisible(Pit.NORTH);
                    }
                    else if (xml.Name.Equals("East"))
                    {
                        pit.setVisible(Pit.EAST);
                    }
                    else if (xml.Name.Equals("West"))
                    {
                        pit.setVisible(Pit.WEST);
                    }
                    else if (xml.Name.Equals("South"))
                    {
                        pit.setVisible(Pit.SOUTH);
                    }

                    break;

                case XmlNodeType.EndElement:

                    if (xml.Name.Equals("Pit"))
                    {
                        return(pit);
                    }

                    break;
                }
            }

            return(pit);
        }
예제 #2
0
        private static Terrain LoadTerrain(XmlTextReader xml)
        {
            int     width, height;
            Terrain terrain = null;

            width  = Int32.Parse(xml.GetAttribute("width"));
            height = Int32.Parse(xml.GetAttribute("height"));

            terrain = new Terrain(width, height);

            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:

                    if (xml.Name.Equals("Tile"))
                    {
                        Tile tile = LoadTile(xml);
                        terrain.SetTile(tile, tile.PosX, tile.PosY);
                    }
                    else if (xml.Name.Equals("Pit"))
                    {
                        Pit pit = LoadPit(xml);
                        terrain.SetTile(pit, pit.PosX, pit.PosY);
                    }
                    else if (xml.Name.Equals("Boundary"))
                    {
                        Boundary boundary = LoadBoundary(xml);
                        terrain.SetTile(boundary, boundary.PosX, boundary.PosY);
                    }

                    break;

                case XmlNodeType.EndElement:

                    if (xml.Name.Equals("Terrain"))
                    {
                        return(terrain);
                    }

                    break;
                }
            }

            return(terrain);
        }
예제 #3
0
        private static Pit LoadPit(XmlTextReader xml)
        {
            int x, y;
            Pit pit = null;

            x = Int32.Parse(xml.GetAttribute("x"));
            y = Int32.Parse(xml.GetAttribute("y"));

            pit = new Pit(x, y);

            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                    case XmlNodeType.Element:

                        if (xml.Name.Equals("North"))
                            pit.setVisible(Pit.NORTH);
                        else if (xml.Name.Equals("East"))
                            pit.setVisible(Pit.EAST);
                        else if (xml.Name.Equals("West"))
                            pit.setVisible(Pit.WEST);
                        else if (xml.Name.Equals("South"))
                            pit.setVisible(Pit.SOUTH);

                        break;

                    case XmlNodeType.EndElement:

                        if (xml.Name.Equals("Pit"))
                            return pit;

                        break;
                }
            }

            return pit;
        }