Esempio n. 1
0
        public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard)
        {
            if (!updateReady)
            {
                updateReady = true;
            }
            if (!dummy.Move && !cleanUp)
            {
                dummy.Move = true;
            }
            headLine.Update(time, null, mouseState);
            dummy.Update(time, null, mouseState);

            foreach (GUI_Element e in elements)
            {
                e.Update(time, null, mouseState);
            }

            if ((returnButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) ||
                keyboard.IsKeyDown(Keys.Back) || (keyboard.IsKeyDown(Keys.Escape)))
            {
                dummy.Move = false;
                cleanUp    = true;
                returnButton.SpriteColor = Color.Gray;
            }

            if (cleanUp && book.CurrentRectangle.Y <= -500 && pressedButton == null)
            {
                pressedButton = returnButton;
            }
        }
Esempio n. 2
0
        public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard)
        {
            startButton.Update(time, null, mouseState);
            dummy.Update(time, null, mouseState);

            foreach (GUI_Element e in elements)
            {
                e.Update(time, null, mouseState);
            }

            FadeIn(time);

            if (visible)
            {
                if (!all.Contains(fireLogo))
                {
                    all.Add(fireLogo);
                }
                burnedLerpCounter -= (float)time.ElapsedGameTime.Milliseconds / 1500;
                if (burnedLerpCounter < 0)
                {
                    burnedLerpCounter = 0;
                }
                fireLerpCounter += (float)time.ElapsedGameTime.Milliseconds / 1500;
                if (fireLerpCounter > 1)
                {
                    fireLerpCounter = 1;
                }
                fireLogo.SpriteColor = new Color(fireLerpCounter, fireLerpCounter, fireLerpCounter, fireLerpCounter);
            }

            if ((startButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) ||
                (keyboard.IsKeyDown(Keys.Enter)) &&
                !fadeOut)
            {
                dummy.Move = false;
                cleanUp    = true;
                startButton.SpriteColor = Color.Gray;
            }

            if (cleanUp && fireLogo.CurrentRectangle.Y <= -500 && pressedButton == null)
            {
                pressedButton = startButton;
            }
        }
Esempio n. 3
0
        public static void update(GameTime time, MouseState mouseState, MouseState lastMouseState, KeyboardState keyboard)
        {
            if (!updateReady)
            {
                updateReady = true;
            }
            if (!dummy.Move && !cleanUp)
            {
                dummy.Move = true;
            }
            headLine.Update(time, null, mouseState);
            dummy.Update(time, null, mouseState);

            foreach (GUI_Element e in elements)
            {
                e.Update(time, null, mouseState);
            }

            if (fullscreenButton.Rectangle.Contains(mouseState.X, mouseState.Y) &&
                lastMouseState.LeftButton == ButtonState.Released &&
                mouseState.LeftButton == ButtonState.Pressed)
            {
                fullscreen = !fullscreen;
                //buttonPressed = true;
            }

            if (tutorialButton.Rectangle.Contains(mouseState.X, mouseState.Y) &&
                lastMouseState.LeftButton == ButtonState.Released &&
                mouseState.LeftButton == ButtonState.Pressed)
            {
                help = !help;
                //buttonPressed = true;
            }

            if (brightnessUp.Rectangle.Contains(mouseState.X, mouseState.Y) &&
                lastMouseState.LeftButton == ButtonState.Released &&
                mouseState.LeftButton == ButtonState.Pressed)
            {
                if (brightness < 10)
                {
                    brightness++;
                    UpdateBook();
                }
            }

            if (brightnessDown.Rectangle.Contains(mouseState.X, mouseState.Y) &&
                lastMouseState.LeftButton == ButtonState.Released &&
                mouseState.LeftButton == ButtonState.Pressed)
            {
                if (brightness > 1)
                {
                    brightness--;
                    UpdateBook();
                }
            }



            //if (!(fullscreenButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) &&
            //   !keyboard.IsKeyDown(Keys.Enter) && buttonPressed)
            //{
            //    buttonPressed = false;
            //}
            //if (!(tutorialButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) &&
            //   !keyboard.IsKeyDown(Keys.Enter) && buttonPressed)
            //{
            //    buttonPressed = false;
            //}


            if (fullscreen)
            {
                fullscreenButton.Text = "  On";
            }
            else
            {
                fullscreenButton.Text = "  Off";
            }
            if (help)
            {
                tutorialButton.Text = "  On";
            }
            else
            {
                tutorialButton.Text = "  Off";
            }

            if ((returnButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) ||
                keyboard.IsKeyDown(Keys.Back) || (keyboard.IsKeyDown(Keys.Escape)))
            {
                dummy.Move = false;
                cleanUp    = true;
                returnButton.SpriteColor = Color.Gray;
            }

            if (cleanUp && book.CurrentRectangle.Y <= -500 && pressedButton == null)
            {
                pressedButton = returnButton;
            }
        }
Esempio n. 4
0
        public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard)
        {
            if (!updateReady)
            {
                updateReady = true;
            }
            foreach (GUI_Element b in buttons)
            {
                b.Update(time, null, mouseState);
            }
            if (!dummy.Move && !cleanUp)
            {
                dummy.Move = true;
            }
            headLine.Update(time, null, mouseState);
            dummy.Update(time, null, mouseState);

            if (cleanUp)
            {
                FadeOut(time);
            }
            else
            {
                bool mouseMoving = false;
                if ((oldMouseState.X != mouseState.X) || (oldMouseState.Y != mouseState.Y))
                {
                    mouseMoving   = true;
                    oldMouseState = mouseState;
                }

                if (currentSelectedButton == null)
                {
                    if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown)
                    {
                        currentSelectedButton = buttons[0];
                        buttonCounter         = 0;
                        keyIsDown             = true;
                    }

                    if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown)
                    {
                        currentSelectedButton = buttons[buttons.Count - 1];
                        buttonCounter         = buttons.Count - 1;
                        keyIsDown             = true;
                    }
                }
                else
                {
                    if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown)
                    {
                        buttonCounter++;
                        buttonCounter        %= (buttons.Count);
                        currentSelectedButton = buttons[buttonCounter];
                        keyIsDown             = true;
                    }

                    if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown)
                    {
                        buttonCounter--;
                        if (buttonCounter < 0)
                        {
                            buttonCounter = buttons.Count - 1;
                        }
                        buttonCounter        %= (buttons.Count);
                        currentSelectedButton = buttons[buttonCounter];
                        keyIsDown             = true;
                    }
                }
                GUI_Element mouseSelection = null;
                int         buttonNumer = 0, mouseNumer = 0;
                foreach (GUI_Element b in buttons)
                {
                    if (b.SpriteColor == Color.Gray)
                    {
                        mouseSelection = b;
                        mouseNumer     = buttonNumer;
                    }
                    buttonNumer++;
                }
                if (mouseSelection != null && mouseSelection != currentSelectedButton && mouseMoving)
                {
                    buttonCounter         = mouseNumer;
                    currentSelectedButton = mouseSelection;
                }
                if (mouseSelection != null && mouseSelection != currentSelectedButton && !mouseMoving)
                {
                    mouseSelection.SpriteColor = Color.White;
                }
                if (mouseSelection == null && mouseSelection != currentSelectedButton && mouseMoving)
                {
                    currentSelectedButton.SpriteColor = Color.White;
                    currentSelectedButton             = null;
                }
                if (currentSelectedButton != null && currentSelectedButton.SpriteColor != Color.Gray)
                {
                    currentSelectedButton.SpriteColor = Color.Gray;
                }
                if (!keyboard.IsKeyDown(Keys.Up) && !keyboard.IsKeyDown(Keys.W) && !keyboard.IsKeyDown(Keys.Down) && !keyboard.IsKeyDown(Keys.S))
                {
                    keyIsDown = false;
                }
                if (currentSelectedButton != null &&
                    (mouseState.LeftButton == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Enter)))
                {
                    cleanUp    = true;
                    dummy.Move = false;
                }
            }
        }