Category5.XmlSettingsFile.ReadLevel C# (CSharp) Метод

ReadLevel() приватный статический Метод

private static ReadLevel ( XmlTextReader reader, Microsoft.Xna.Framework.Content.ContentManager content ) : void
reader System.Xml.XmlTextReader
content Microsoft.Xna.Framework.Content.ContentManager
Результат void
        private static void ReadLevel(XmlTextReader reader, ContentManager content)
        {
            string tempString;

            //Move to first attribute for this level
            if (reader.MoveToFirstAttribute())
            {
                //Create a new level type
                LevelConfig tempLevelConfig = new LevelConfig();

                //Loop through all attributes for the Level config
                do
                {
                    try
                    {
                        //Get the attribute name
                        tempString = reader.Name.ToUpper();

                        //Look for definied attributes for level
                        if (tempString == "NAME")
                        {
                            tempLevelConfig.LevelName = reader.Value;
                        }
                        else if (tempString == "MEGATILEWIDTH")
                        {
                            tempLevelConfig.MegaTileWidth = int.Parse(reader.Value);
                        }
                        else if (tempString == "MEGATILEHEIGHT")
                        {
                            tempLevelConfig.MegaTileHeight = int.Parse(reader.Value);
                        }
                        else if (tempString == "LEVELFILE")
                        {
                            tempLevelConfig.LevelFile = reader.Value;
                        }
                        else if (tempString == "STARTX")
                        {
                            tempLevelConfig.StartX = int.Parse(reader.Value);
                        }
                        else if (tempString == "STARTY")
                        {
                            tempLevelConfig.StartY = int.Parse(reader.Value);
                        }
                        else if (tempString == "TORNADOSHRINKFACTOR")
                        {
                            tempLevelConfig.TornadoShrinkFactor = float.Parse(reader.Value);
                        }
                        //Handle undefined level attributes

                        else
                        {
                            throw new ApplicationException("Invalid Level Config attribute '" + tempString + "' on line " + reader.LineNumber);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new ApplicationException("Error parsing Level Config attribute on line " + reader.LineNumber +
                                ": " + e.Message);
                    }

                } while (reader.MoveToNextAttribute());

                //Add the level config object to the list
                levelConfigs.Add(tempLevelConfig);
            }
        }