예제 #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);
        }
예제 #2
0
        /// <summary>
        /// Game logic function.  Update world, handle input, etc
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            int           Seconds   = gameTime.TotalGameTime.Seconds;
            KeyboardState KeyState  = Keyboard.GetState();
            MouseState    CurrMouse = Mouse.GetState();

            if ((PriorKeyState.IsKeyDown(Keys.OemTilde) == false) && (KeyState.IsKeyDown(Keys.OemTilde) == true))
            {
                DevConsole.ToggleVisible();
            }

            DevConsole.Update(gameTime, Keyboard.GetState(), Mouse.GetState());

            if ((PriorMouseState.LeftButton == ButtonState.Released) && (CurrMouse.LeftButton == ButtonState.Pressed))
            {
                DevConsole.AddText("Left mouse clicked, X=" + CurrMouse.X + " Y=" + CurrMouse.Y);
            }

            if (new Rectangle(10, 10, CardBack.Width, CardBack.Height).Contains(CurrMouse.X, CurrMouse.Y))
            {
                if (cMouseOverCard == false)
                {
                    DevConsole.AddText("Mouse entered card");
                    cMouseEnterTime  = gameTime.TotalGameTime.TotalMilliseconds;
                    cMouseOverCard   = true;
                    TestCont.Visible = true;
                }
            }
            else
            {
                if (cMouseOverCard == true)
                {
                    DevConsole.AddText("Mouse exited card");
                    cMouseOverCard   = false;
                    TestCont.Visible = false;
                }
            }

            if (cMouseEnterTime != -1)
            {
                if (gameTime.TotalGameTime.TotalMilliseconds - cMouseEnterTime >= 500)
                {
                    DevConsole.AddText("Mouse over 500 ms elapsed");
                    cMouseEnterTime = -1;
                }
            }

            TestCont.Update(gameTime);

            PriorMouseState = CurrMouse;
            PriorKeyState   = KeyState;

            FrameNum = (Seconds % 6) + 1;

            if (gameTime.TotalGameTime.Milliseconds <= 500)
            {
                Transparency = gameTime.TotalGameTime.Milliseconds / 2;
            }
            else
            {
                Transparency = 255 - ((gameTime.TotalGameTime.Milliseconds - 500) / 2);
            }

            if (cShipUseKeys == true)
            {
                if (KeyState.IsKeyDown(Keys.Left) == true)
                {
                    cShipDir = ShipDirection.Left;
                }
                else if (KeyState.IsKeyDown(Keys.Right) == true)
                {
                    cShipDir = ShipDirection.Right;
                }
                else
                {
                    cShipDir = ShipDirection.Straight;
                }
            }
            else
            {
                if (CurrMouse.Position.X < 300)
                {
                    cShipDir = ShipDirection.Left;
                }
                else if (CurrMouse.Position.X > 500)
                {
                    cShipDir = ShipDirection.Right;
                }
                else
                {
                    cShipDir = ShipDirection.Straight;
                }
            }

            TestCard.Update(gameTime);

            NestedCont.Update(gameTime);

            cTextTest.Update(gameTime);

            //Use monogame update
            base.Update(gameTime);
        }