Пример #1
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            lastState    = currentState;
            currentState = Mouse.GetState();

            if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[0].Texture = easy_select;
            }
            else
            {
                bl[0].Texture = easy;
            }

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

            if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[2].Texture = hard_select;
            }
            else
            {
                bl[2].Texture = hard;
            }

            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to change the Game's difficulty to "Easy" (1)
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    GameSpecs.Difficulty = 1;
                    return(GameState.Running);
                }

                // Button to change the Game's difficulty to "Medium" (2)
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    GameSpecs.Difficulty = 2;
                    return(GameState.Running);
                }

                // Button to change the Game's difficulty to "Hard" (3)
                if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    GameSpecs.Difficulty = 3;
                    return(GameState.Running);
                }
            }

            return(GameState.ChooseDifficulty);
        }
Пример #2
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            lastState    = currentState;
            currentState = Mouse.GetState();

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

            if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                if (GameSpecs.SoundOn)
                {
                    bl[1].Texture = sound_select;
                }
                else
                {
                    bl[1].Texture = noSound_select;
                }
            }
            else
            {
                if (GameSpecs.SoundOn)
                {
                    bl[1].Texture = sound;
                }
                else
                {
                    bl[1].Texture = noSound;
                }
            }

            if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                if (GameSpecs.MusicOn)
                {
                    bl[2].Texture = sound2_select;
                }
                else
                {
                    bl[2].Texture = noSound2_select;
                }
            }
            else
            {
                if (GameSpecs.MusicOn)
                {
                    bl[2].Texture = sound2;
                }
                else
                {
                    bl[2].Texture = noSound2;
                }
            }

            // Click-Check-Routine
            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to return to MainMenu-Screen
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    Thread.Sleep(200);
                    GameSpecs.PreviousGamestate = GameState.OptionMenu;
                    return(GameState.MainMenuNoSession);
                }
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    if (GameSpecs.SoundOn)
                    {
                        Extension.MuteUnmuteClickSounds();
                        Thread.Sleep(150);
                    }
                    else
                    {
                        Extension.MuteUnmuteClickSounds();
                    }
                }
                if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    if (GameSpecs.MusicOn)
                    {
                        Extension.MuteMusic();
                        GameSpecs.MusicOn = false;
                        Thread.Sleep(150);
                    }
                    else
                    {
                        Extension.UnmuteMusic();
                        GameSpecs.MusicOn = true;
                        Thread.Sleep(150);
                    }
                }
            }

            return(GameState.OptionMenu);
        }
Пример #3
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            KeyboardState kbState = Keyboard.GetState();

            lastState    = currentState;
            currentState = Mouse.GetState();

            // Current Position of the mouse-cursor
            Point p = new Point(currentState.X, currentState.Y);

            // Hover-Check-Routine for the Button(s)
            if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[0].Texture = backArrow_select;
            }
            else
            {
                bl[0].Texture = backArrow;
            }

            // Starts to run down the Highscore if the Timer is active
            if (Timer.Running == true)
            {
                if (Timer.GetScore() > 0.0)
                {
                    // Use timer to determine the Score
                    Timer.Score -= gameTime.ElapsedGameTime.TotalMilliseconds / 60;
                }
            }

            /// <summary>
            /// Ends the Game if the score hits 0 while gaming
            /// </summary>
            if (Timer.Score == 0)
            {
                Thread.Sleep(200);
                Session.Gameover = true;
                return(GameState.Endgame);
            }

            /// <summary>
            /// Checks if the players have won the game (a.k.a. matched all possible pairs)
            /// </summary>
            if (Session.PairsUntilWin == 0)
            {
                Timer.StopTimer();

                Thread.Sleep(200);
                /// Implement optional winning-sound-playing here

                // Returns the Endgame state if the players have turned all cards correctly within the given time
                return(GameState.Endgame);
            }

            // Temporary solution to get to the highscores prematurely
            if (kbState.IsKeyDown(Keys.F))
            {
                return(GameState.Highscore);
            }

            // Temporary solution to get to the Success-Screen prematurely
            if (kbState.IsKeyDown(Keys.H))
            {
                Countdown.Initialize(10);
                return(GameState.Endgame);
            }

            /// <summary>
            /// Checks if the players paired up two cards of the same kind and runs the according logic
            /// </summary>
            if (Session.TurnedCards.Count == 2)
            {
                Thread.Sleep(200);
                if (Session.TurnedCards[0].MotiveID == Session.TurnedCards[1].MotiveID)
                {
                    cardList[Session.TurnedCards[0].Id].CurrentTexture = correct;
                    cardList[Session.TurnedCards[1].Id].CurrentTexture = correct;
                    Session.ResetTurnedCards();
                    Session.PairsUntilWin--;
                    Thread.Sleep(200);
                }
                else
                {
                    cardList[Session.TurnedCards[0].Id].CurrentTexture = backside;
                    cardList[Session.TurnedCards[1].Id].CurrentTexture = backside;
                    Session.ResetTurnedCards();
                    Thread.Sleep(200);
                }
            }

            // Click-Check-Routine
            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to return to MainMenu-Screen
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    Thread.Sleep(20);
                    return(GameState.MainMenuSession);
                }

                Thread.Sleep(20);
                int index = 0;
                foreach (Card c in cardList)
                {
                    if (c.Zone.Contains(p))
                    {
                        Extension.PlaySoundEffect("cardFlip");
                        // Performs a check if a card is already turned before running the Gamelogic for turning
                        if (c.CurrentTexture != correct)
                        {
                            switch (Session.TurnedCards.Count)
                            {
                            case 0:
                            {
                                c.CurrentTexture = LoadTextureByMotive(c.MotiveID);
                                c.Id             = index;
                                Session.TurnedCards.Add(c);
                                Thread.Sleep(20);
                                break;
                            }

                            case 1:
                            {
                                if (c.Id != Session.TurnedCards[0].Id)
                                {
                                    c.CurrentTexture = LoadTextureByMotive(c.MotiveID);
                                    c.Id             = index;
                                    Session.TurnedCards.Add(c);
                                    Thread.Sleep(20);
                                    break;
                                }
                                else
                                {
                                    index--;
                                    break;
                                }
                            }
                            }
                        }
                    }
                    index++;
                }
            }

            // Hover-Implementation to test Card-Zoning
            foreach (Card c in cardList)
            {
                if (c.Zone.Contains(p))
                {
                    GameSpecs.CurrentCard = c.MotiveID;
                }
            }

            // Button-Press to Pause the Game
            if (kbState.IsKeyDown(Keys.Escape))
            {
                Thread.Sleep(100);
                return(GameState.MainMenuSession);
            }

            else
            {
                return(GameState.Running);
            }
        }
Пример #4
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);
        }
Пример #5
0
        public GameState Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            lastState    = currentState;
            currentState = Mouse.GetState();

            // Hover-Check-Routine for the Button(s)
            if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[0].Texture = backArrow_select;
            }
            else
            {
                bl[0].Texture = backArrow;
            }

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

            if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[2].Texture = button_photo_select;
            }
            else
            {
                bl[2].Texture = button_photo;
            }

            if (bl[3].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[3].Texture = button_photo_select;
            }
            else
            {
                bl[3].Texture = button_photo;
            }

            if (bl[4].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[4].Texture = button_photo_select;
            }
            else
            {
                bl[4].Texture = button_photo;
            }

            if (bl[5].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[5].Texture = button_photo_select;
            }
            else
            {
                bl[5].Texture = button_photo;
            }

            if (bl[6].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[6].Texture = button_photo_select;
            }
            else
            {
                bl[6].Texture = button_photo;
            }

            if (bl[7].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[7].Texture = button_photo_select;
            }
            else
            {
                bl[7].Texture = button_photo;
            }

            if (bl[8].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[8].Texture = button_photo_select;
            }
            else
            {
                bl[8].Texture = button_photo;
            }

            if (bl[9].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[9].Texture = button_photo_select;
            }
            else
            {
                bl[9].Texture = button_photo;
            }

            if (bl[10].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[10].Texture = button_photo_select;
            }
            else
            {
                bl[10].Texture = button_photo;
            }

            if (bl[11].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
            {
                bl[11].Texture = button_photo_select;
            }
            else
            {
                bl[11].Texture = button_photo;
            }

            // Click-Check-Routine
            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to return to MainMenu-Screen
                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    Thread.Sleep(200);
                    GameSpecs.PreviousGamestate = GameState.Highscore;
                    Session.ResetSession();
                    return(GameState.MainMenuNoSession);
                }

                // Button to directly re-run for a new game
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    Thread.Sleep(200);
                    GameSpecs.PreviousGamestate = GameState.Highscore;
                    Session.ResetSession();
                    return(GameState.ChooseDifficulty);
                }
                // Button to go to detailview for extended picture
                if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[0], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[3].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[1], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[4].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[2], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[5].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[3], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[6].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[4], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[7].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[5], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[8].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[6], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[9].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[7], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[10].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[8], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
                // Button to go to detailview for extended picture
                if (bl[11].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    Extension.PlaySoundEffect("menuClick");
                    g.Clear(Color.Black);
                    GameSpecs.DetailPicture = DatabaseConnection.ReadSingleImage(Session.LatestScoreBoard[9], GameSpecs.Difficulty);
                    Thread.Sleep(200);
                    return(GameState.ImageDetailView);
                }
            }

            return(GameState.Highscore);
        }
Пример #6
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 = newGame_select;
            }
            else
            {
                bl[0].Texture = newGame;
            }

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

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

            // Check-Routine for catching clicks on the buttons
            if (currentState.LeftButton == ButtonState.Released && lastState.LeftButton == ButtonState.Pressed)
            {
                // Button to start game

                if (bl[0].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    Extension.SetStates(ref currentState, ref lastState);

                    return(GameState.ChooseDifficulty);
                }

                // Button to open optionsmenu
                if (bl[1].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    Extension.SetStates(ref currentState, ref lastState);
                    return(GameState.OptionMenu);
                }

                // Button to end game
                if (bl[2].ClickTangle.Contains(new Point(currentState.X, currentState.Y)))
                {
                    g.Clear(Color.Black);
                    Extension.PlaySoundEffect("menuClick");
                    Thread.Sleep(200);
                    Extension.SetStates(ref currentState, ref lastState);

                    Extension.ShutDownKinect();

                    return(GameState.None);
                }
            }

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

            else
            {
                Extension.SetStates(ref currentState, ref lastState);
                return(GameState.MainMenuNoSession);
            }
        }
Пример #7
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);
            }
        }