Ejemplo n.º 1
0
        public Scene(MenuSystem menuSystem, TextSection textSection,
                     SpriteManager spriteManager, AnimationManager animationManager,
                     SoundManager soundManager, FontMap fontMap)
        {
            m_endTime = textSection.GetAttribute <int>("end.time");
            var clearColor = textSection.GetAttribute("clearcolor", (Vector3?)null);

            if (clearColor.HasValue)
            {
                ClearColor = new Color(clearColor.Value);
            }
            Position = textSection.GetAttribute("layerall.pos", (Vector2?)null);
            var collection = new Collection(spriteManager, animationManager, soundManager, fontMap);

            m_videoSystem = menuSystem.GetSubSystem <VideoSystem>();
            m_spriteBatch = new SpriteBatch(m_videoSystem.Device);

            m_fader  = new Fader(m_videoSystem.EmptyTexture, textSection);
            m_layers = new Layer[10];
            for (var i = 0; i < m_layers.Length; i++)
            {
                m_layers[i] = new Layer();
                var prefix = $"layer{i}";
                if (textSection.HasAttribute($"{prefix}.starttime"))
                {
                    m_layers[i].StartTime = textSection.GetAttribute <int>($"{prefix}.starttime");
                }
                if (textSection.HasAttribute($"{prefix}.anim"))
                {
                    m_layers[i].AnimatedImage = (AnimatedImage)collection.Build(textSection, prefix);
                }
                if (textSection.HasAttribute($"{prefix}.offset"))
                {
                    m_layers[i].Offset = textSection.GetAttribute <Vector2>($"{prefix}.offset");
                }
            }
        }