Exemplo n.º 1
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            lastState    = currentState;
            currentState = Mouse.GetState();

            // Runs the counter-logic if the countdown has not yet reached zero
            if (Countdown.Counter > 0.0)
            {
                Countdown.Counter -= gameTime.ElapsedGameTime.TotalMilliseconds / 600;
            }
            else
            {
                // Sets the flag to true to indicate that it is time to make the photo
                GameSpecs.PhotoTimerUp = true;

                // Sets the PhotoTaken-marker to true
                Session.PhotoTaken = true;
            }

            // Hover-Check-Routines
            if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[0].Texture = yes_select;
            }
            else
            {
                bl[0].Texture = yes;
            }

            if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[1].Texture = no_select;
            }
            else
            {
                bl[1].Texture = no;
            }

            // Check-Routine for catching clicks on the buttons
            if (currentState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released && lastState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                // Button to confirm the photo
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    if (GameSpecs.PhotoTimerUp)
                    {
                        Extension.PlaySoundEffect("menuClick");
                        Thread.Sleep(200);
                        GameSpecs.PreviousGamestate = GameState.Endgame;
                        return(GameState.Highscore);
                    }
                }

                // Button to retry taking the photo
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    if (GameSpecs.PhotoTimerUp)
                    {
                        GameSpecs.PhotoTimerUp = false;
                        Session.PhotoTaken     = false;
                        GameSpecs.PhotoSwitch  = false;
                        Countdown.Counter      = 10;
                        Extension.PlaySoundEffect("menuClick");
                        Thread.Sleep(10);
                    }
                }
            }

            // Insert the value of the highscore to the Database. // Temporary Solution though
            if (Session.ValueInserted == false)
            {
                // Extension.AddValueToDB((int)Timer.Score);
                Thread.Sleep(400);
                Session.ValueInserted = true;
            }

            return(GameState.Endgame);
        }
Exemplo n.º 2
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            lastState    = currentState;
            currentState = Mouse.GetState();

            KeyboardState kbState = Keyboard.GetState();

            // Hover-Check-Routines
            if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[0].Texture = resume_select;
            }
            else
            {
                bl[0].Texture = resume;
            }

            if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[1].Texture = quit_select;
            }
            else
            {
                bl[1].Texture = quit;
            }

            // Check-Routine for catching clicks on the buttons
            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to resume game
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    GameSpecs.PreviousGamestate = GameState.MainMenuSession;
                    Extension.SetStates(ref currentState, ref lastState);
                    return(GameState.Running);
                }

                // Button to end session
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Session.ResetSession();
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    GameSpecs.PreviousGamestate = GameState.MainMenuSession;
                    Extension.SetStates(ref currentState, ref lastState);
                    return(GameState.MainMenuNoSession);
                }
            }

            if (kbState.IsKeyDown(Keys.Escape))
            {
                g.Clear(Color.Black);
                Thread.Sleep(200);
                return(GameState.Running);
            }

            else
            {
                Extension.SetStates(ref currentState, ref lastState);
                return(GameState.MainMenuSession);
            }
        }