Beispiel #1
0
        public void Load(CustomSpriteBatch spriteBatch, XmlTag xmlSheet, string strTextureFilename)
        {
            Debug.Assert(ans_pTexture == null);

            ans_pSpriteBatch       = spriteBatch;
            ans_strTextureFilename = strTextureFilename;
            ans_pTexture           = ContentRegister.Texture(strTextureFilename);

            if (xmlSheet.Attributes.ContainsKey("name"))
            {
                ans_strName = xmlSheet.Attributes["name"];
            }

            XmlTag[] xmlAnimations;
            xmlAnimations = xmlSheet.FindTagsByName("anim");

            for (int i = 0; i < xmlAnimations.Length; i++)
            {
                XmlTag    tag  = xmlAnimations[i];
                Animation anim = new Animation();
                anim.ani_pSheet = this;
                anim.Load(tag);
                ans_saAnimations.Add(anim);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Call this to start initialization of all necessary classes.
        /// </summary>
        public static void Initialize(Game game, GraphicsDeviceManager graphics, CustomSpriteBatch spritebatch, GraphicsDevice graphicsDevice)
        {
            // remember for later
            Game        = game;
            Graphics    = graphics;
            SpriteBatch = spritebatch;

            // load Mrag.ini if present
            if (File.Exists("Mrag.ini"))
            {
                Config config = new Config("Mrag.ini");
                if (config.HasGroup("MRAG"))
                {
                    game.IsMouseVisible = config.GetBool("MRAG", "MouseVisible");
                    graphics.PreferredBackBufferWidth  = config.GetInt("MRAG", "ScreenWidth");
                    graphics.PreferredBackBufferHeight = config.GetInt("MRAG", "ScreenHeight");
                    graphics.IsFullScreen = config.GetBool("MRAG", "FullScreen");
                    graphics.SynchronizeWithVerticalRetrace = config.GetBool("MRAG", "Vsync");
                    graphics.ApplyChanges();
                }
            }

            // load the default font from resources
            SpriteBatch.LoadDefaultFont();

            // set up lighting target for spritebatch
            SpriteBatch.lightingTarget = new RenderTarget2D(graphicsDevice, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);

            // initialize individual required components
            ContentRegister.Initialize(game.Content);

            // create pixel for spritebatch
            if (SpriteBatch != null)
            {
                SpriteBatch.Pixel = new Texture2D(game.GraphicsDevice, 1, 1);
                SpriteBatch.Pixel.SetData <Color>(new Color[] { Color.White });
            }

            // initialize GUI
            GUI.GUI.Initialize();
        }
Beispiel #3
0
        internal void Render(CustomSpriteBatch sb)
        {
            System.Drawing.Bitmap bmp = Resources.Light;
            if (Variation == 1)
            {
                bmp = Resources.Light2;
            }

            sb.Draw(ContentRegister.BitmapToTexture(bmp, "Resource_Light" + Variation),
                    new RotRect(Position + Offset, new Vector2(Falloff))
            {
                anchorInCenter = true
            },
                    Color);

            if (Dynamic)
            {
                if (DynamicDebug)
                {
                }
            }
        }