public static void Exit()
 {
     DevConsole.Close();
 }
Example #2
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            //dev log
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.F1) && prevKeyboard.IsKeyUp(Keys.F1))
            {
                if (devConsole.IsOpen())
                {
                    devConsole.Close();
                }
                else
                {
                    devConsole.Open();
                }
            }

            if (keyboard.IsKeyDown(Keys.C) && prevKeyboard.IsKeyUp(Keys.C))
            {
                if (tempChest.IsOpen())
                {
                    tempChest.Close();
                }
                else if (!tempChest.IsOpen())
                {
                    tempChest.Open();
                }
            }

            devConsole.Update();
            //input-mouse

            MouseState mouse        = Mouse.GetState();
            Vector2    realMousePos = camera.ScreenToWorld(new Vector2(mouse.Position.X, mouse.Position.Y));

            cursorPosition = realMousePos;

            if (!devConsole.IsOpen())
            {
                player.Update();
                trainingDummy.Update();

                if (mouse.LeftButton == ButtonState.Pressed && prevMouse.LeftButton == ButtonState.Released)
                {
                    if (trainingDummy.bounds.Intersects(new Rectangle((int)realMousePos.X, (int)realMousePos.Y, 8, 8)))
                    {
                        trainingDummy.Hit();
                    }
                }

                if (player.bounds.Y < trainingDummy.GetPosition().Y)
                {
                    trainingDummy.depth = 0.4f;
                }
                else
                {
                    trainingDummy.depth = 0.7f;
                }
            }

            if (currentFrameTime > frameRate)
            {
                if (currentFrame < (torchTexture.Width / 16) - 1)
                {
                    currentFrame++;
                }
                else
                {
                    currentFrame = 0;
                }

                currentFrameTime = 0;
            }
            else
            {
                currentFrameTime++;
            }

            tempChest.Update();
            camera.SetPosition(player.GetPosition());
            prevMouse    = mouse;
            prevKeyboard = keyboard;
        }