Esempio n. 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            Color Overlay = new Color(255, 255, 255, Transparency);

            GraphicsDevice.Clear(Color.Blue);

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);

            switch (FrameNum)
            {
            case 1:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(0, 0, 114, 114), Overlay);
                break;

            case 2:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(115, 0, 114, 114), Overlay);
                break;

            case 3:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(230, 0, 114, 114), Overlay);
                break;

            case 4:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(345, 0, 114, 114), Overlay);
                break;

            case 5:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(0, 115, 114, 114), Overlay);
                break;

            case 6:
                spriteBatch.Draw(background, GraphicsDevice.Viewport.Bounds, new Rectangle(115, 115, 114, 114), Overlay);
                break;
            }

            spriteBatch.Draw(CardBack, new Rectangle(10, 10, CardBack.Width, CardBack.Height), Color.White);

            spriteBatch.Draw(CardImage, new Rectangle(20, 40, 14 * 16, 195 - 40 - 10), Color.White);

            cFont.WriteText(spriteBatch, "Card Name", 20, 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Card Details 1", 195, 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 2", 195 + cFont.CharacterHeight, 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 3", 195 + (cFont.CharacterHeight * 2), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 4", 195 + (cFont.CharacterHeight * 3), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 5", 195 + (cFont.CharacterHeight * 4), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 6", 195 + (cFont.CharacterHeight * 5), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 7", 195 + (cFont.CharacterHeight * 6), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 8", 195 + (cFont.CharacterHeight * 7), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 9", 195 + (cFont.CharacterHeight * 8), 20, Color.DarkBlue);
            cFont.WriteText(spriteBatch, "Line 10", 195 + (cFont.CharacterHeight * 9), 20, Color.DarkBlue);

            cFont.WriteText(spriteBatch, "Small Text", 5, 50, 300, Color.OrangeRed);
            cFont.WriteText(spriteBatch, "Big Text", 40, 60, 300, Color.OrangeRed);

            if (cShipShow == true)
            {
                if (cShipDir == ShipDirection.Straight)
                {
                    spriteBatch.Draw(cShip, new Vector2(300f, 200f), new Rectangle(0, 0, 200, 200), Color.White);
                }
                else if (cShipDir == ShipDirection.Left)
                {
                    spriteBatch.Draw(cShip, new Vector2(300f, 200f), null, new Rectangle(200, 0, 200, 200), null, 0, null, Color.White, SpriteEffects.FlipHorizontally, 0);
                }
                else                     //right
                {
                    spriteBatch.Draw(cShip, new Vector2(300f, 200f), new Rectangle(200, 0, 200, 200), Color.White);
                }
            }

            spriteBatch.End();

            TestCard.Draw();
            TestCont.Draw();

            NestedCont.Draw();

            cTextTest.Draw();

            DevConsole.Draw();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        protected override void Draw(GameTime gameTime)
        {
            Rectangle OverlayRect;
            Vector2   OverlayOrigin;

            cGraphDevMgr.GraphicsDevice.Clear(Color.Black);

            cUFOs.Draw();
            cAsteroids.Draw();
            cEnemyBullets.Draw();
            cPlayerBullets.Draw();

            if (cHeadlightMode == true)              //Dimming overlay for the flashlight
            {
                cDrawBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

                OverlayRect.X      = cPlayerShip.Left + (cPlayerShip.Width / 2);
                OverlayRect.Y      = cPlayerShip.Top + (cPlayerShip.Height / 2);
                OverlayRect.Width  = cTextureDict[Textures.LightFilter].Width * 4 + cGraphDevMgr.GraphicsDevice.Viewport.Width;
                OverlayRect.Height = cTextureDict[Textures.LightFilter].Height * 4 + cGraphDevMgr.GraphicsDevice.Viewport.Height;

                OverlayOrigin.X = cTextureDict[Textures.LightFilter].Width / 2;
                OverlayOrigin.Y = cTextureDict[Textures.LightFilter].Height;

                //cDrawBatch.Draw(cSolidTexture, cGraphDevMgr.GraphicsDevice.Viewport.Bounds, cSolidTexture.Bounds, new Color(255, 0, 0, 255));
                cDrawBatch.Draw(cTextureDict[Textures.LightFilter], OverlayRect, cTextureDict[Textures.LightFilter].Bounds, new Color(255, 200, 255, 250), (float)((Math.PI * 2) - (cPlayerShip.cRotation)), OverlayOrigin, SpriteEffects.None, 0);
                cDrawBatch.Draw(cTextureDict[Textures.LightFilter], OverlayRect, cTextureDict[Textures.LightFilter].Bounds, new Color(255, 200, 255, 250), (float)((Math.PI * 2) - (cPlayerShip.cRotation + Math.PI)), OverlayOrigin, SpriteEffects.FlipHorizontally, 0);

                cDrawBatch.End();
            }

            cPlayerShip.Draw();
            cSparkles.Draw();

            cDevConsole.Draw();

            if (cShowStats == true)
            {
                cDrawBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
                cFont.WriteText(cDrawBatch, string.Format("Asteroids={0} UFOs={1} Bullets={2} Sparkles={3} Kills={4} Max={5} Alive={6:0.00}s", cAsteroids.ParticleList.Count, cUFOs.ParticleList.Count, cPlayerBullets.ParticleList.Count + cEnemyBullets.ParticleList.Count, cSparkles.ParticleList.Count, cEnemyKills, cEnemyKillsMax, gameTime.TotalGameTime.TotalSeconds - cAliveSince), 10, cGraphDevMgr.GraphicsDevice.Viewport.Height - cFont.CharacterHeight, 10, Color.Azure);
                cDrawBatch.End();
            }

            /*
             * Vector2 ShadowOrigin = MGTools.MGMath.CalculateXYMagnitude(cPlayerShip.cRotation, cPlayerShip.Height);
             * Matrix StencilMatrix = Matrix.CreateOrthographicOffCenter(0, cGraphDevMgr.GraphicsDevice.PresentationParameters.BackBufferWidth, cGraphDevMgr.GraphicsDevice.PresentationParameters.BackBufferHeight, 0, 0, 1);
             *
             * var StencilAlphaTest = new AlphaTestEffect(cGraphDevMgr.GraphicsDevice);
             * StencilAlphaTest.Projection = StencilMatrix;
             *
             * DepthStencilState DepthStencilMask = new DepthStencilState();
             * DepthStencilMask.StencilEnable = true;
             * DepthStencilMask.StencilFunction = CompareFunction.Always;
             * DepthStencilMask.StencilPass = StencilOperation.Replace;
             * DepthStencilMask.ReferenceStencil = 1;
             * DepthStencilMask.DepthBufferEnable = false;
             *
             * DepthStencilState DepthStencilDraw = new DepthStencilState {
             *      StencilEnable = true,
             *      StencilFunction = CompareFunction.LessEqual,
             *      StencilPass = StencilOperation.Keep,
             *      ReferenceStencil = 1,
             *      DepthBufferEnable = false,
             * };
             *
             * cDrawBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, DepthStencilMask, null, StencilAlphaTest);
             * cDrawBatch.Draw(cSolidTexture, new Rectangle((int)(cPlayerShip.Left + (cPlayerShip.Width / 2) - ShadowOrigin.X), (int)(cPlayerShip.Top + (cPlayerShip.Height / 2) + ShadowOrigin.Y), cGraphDevMgr.GraphicsDevice.Viewport.Width * 2, cGraphDevMgr.GraphicsDevice.Viewport.Height * 2), cSolidTexture.Bounds, new Color(0,0,0,0), (float)(2 * Math.PI - cPlayerShip.cRotation + 1.0472), Vector2.Zero, SpriteEffects.None, 0);
             * cDrawBatch.Draw(cSolidTexture, new Rectangle((int)(cPlayerShip.Left + (cPlayerShip.Width / 2) - ShadowOrigin.X), (int)(cPlayerShip.Top + (cPlayerShip.Height / 2) + ShadowOrigin.Y), cGraphDevMgr.GraphicsDevice.Viewport.Width * 2, cGraphDevMgr.GraphicsDevice.Viewport.Height * 2), cSolidTexture.Bounds, new Color(0,0,0,0), (float)(2 * Math.PI - cPlayerShip.cRotation - 2.618), Vector2.Zero, SpriteEffects.None, 0);
             * cDrawBatch.Draw(cSolidTexture, new Rectangle((int)(cPlayerShip.Left + (cPlayerShip.Width / 2) - ShadowOrigin.X), (int)(cPlayerShip.Top + (cPlayerShip.Height / 2) + ShadowOrigin.Y), cGraphDevMgr.GraphicsDevice.Viewport.Width * 2, cGraphDevMgr.GraphicsDevice.Viewport.Height * 2), cSolidTexture.Bounds, new Color(0,0,0,0), (float)(2 * Math.PI - cPlayerShip.cRotation + (Math.PI / 2)), Vector2.Zero, SpriteEffects.None, 0);
             * cDrawBatch.Draw(cSolidTexture, new Rectangle((int)(cPlayerShip.Left + (cPlayerShip.Width / 2) - ShadowOrigin.X), (int)(cPlayerShip.Top + (cPlayerShip.Height / 2) + ShadowOrigin.Y), cGraphDevMgr.GraphicsDevice.Viewport.Width * 2, cGraphDevMgr.GraphicsDevice.Viewport.Height * 2), cSolidTexture.Bounds, new Color(0,0,0,0), (float)(2 * Math.PI - cPlayerShip.cRotation + Math.PI), Vector2.Zero, SpriteEffects.None, 0);
             * cDrawBatch.End();
             *
             * cDrawBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilDraw, null, StencilAlphaTest); //Draw stuff to be masked
             * cDrawBatch.Draw(cTextureDict[Textures.Asteroid], cGraphDevMgr.GraphicsDevice.Viewport.Bounds, new Color(0, 0, 0, 100)); //Uses
             * cDrawBatch.End();
             */
            //Use monogame draw
            base.Draw(gameTime);
        }