MrGravity.LevelChoice.LevelChoice C# (CSharp) Méthode

LevelChoice() public méthode

public LevelChoice ( System.Xml.Linq.XElement levelInfo, IControlScheme controls, Microsoft.Xna.Framework.Content.ContentManager content, GraphicsDevice graphics ) : System
levelInfo System.Xml.Linq.XElement
controls IControlScheme
content Microsoft.Xna.Framework.Content.ContentManager
graphics GraphicsDevice
Résultat System
        public LevelChoice(XElement levelInfo, IControlScheme controls, ContentManager content, GraphicsDevice graphics)
        {
            foreach(var element in levelInfo.Elements())
            {
                if (element.Name == XmlKeys.LevelName)
                {
                    Level = new Level(LevelSelect.LevelDirectory + element.Value + ".xml", controls, graphics.Viewport);

            #if XBOX360
                    mThumbnail = content.Load<Texture2D>("Levels\\Thumbnail\\" + element.Value.ToString());
            #else
                    FileStream filestream;
                    try
                    {
                        filestream = new FileStream(LevelSelect.LevelThumbsDirectory + element.Value + ".png", FileMode.Open);
                    }
                    catch (IOException e)
                    {
                        var err = e.ToString();
                        filestream = new FileStream(LevelSelect.LevelThumbsDirectory + "..\\..\\..\\Content\\Images\\Error.png", FileMode.Open);
                    }
                    Thumbnail = Texture2D.FromStream(graphics, filestream);
                    filestream.Close();
            #endif
                }
                if (element.Name == XmlKeys.Unlocked)
                    Unlocked = element.Value == XmlKeys.True;

                if (element.Name == XmlKeys.Timerstar)
                    TimerStar = Level.TimerStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Collectionstar)
                    CollectionStar = Level.CollectionStar = Convert.ToInt32(element.Value);

                if (element.Name == XmlKeys.Deathstar)
                    DeathStar = Level.DeathStar = Convert.ToInt32(element.Value);
            }
        }