Exemple #1
0
        public override void Update(GameTime gameTime)
        {
            if (currentState == GameState.START)
            {
                gameOverShown = true;
                startScreen.SetData(GameState.START);
                currentState = GameState.START;
                //Music-------------------------------------------
                if (((TankGame)Game).soundManager.endingPlaying)
                    ((TankGame)Game).soundManager.stopEnd();
                if(!((TankGame)Game).soundManager.introPlaying)
                    ((TankGame)Game).soundManager.playIntro();
                //------------------------------------------------
            }

            if ((Keyboard.GetState().IsKeyDown(Keys.Enter) && !enterPressed) || GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A))
            {
                if (currentState == GameState.START)
                {
                    ChangeGameState(GameState.MOVEHINT);
                    hintScreen = new MoveHintScreen((TankGame)Game);
                    ((TankGame)Game).noDebug();
                    //Music---------------------------------------------
                    if (((TankGame)Game).soundManager.introPlaying)
                        ((TankGame)Game).soundManager.stopIntro();
                    if (!((TankGame)Game).soundManager.backgroundPlaying)
                        ((TankGame)Game).soundManager.playBackground();
                    //--------------------------------------------------
                    ((TankGame)Game).Components.Add(hintScreen);
                }
            }

            if((Keyboard.GetState().IsKeyDown(Keys.Z)) && !debugPressed)
            {
                ChangeGameState(GameState.PLAYER1);
                debugPressed = true;
                ((TankGame)Game).startDebug();
            }

            if (currentState == GameState.MOVEHINT)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.A) ||
                    Keyboard.GetState().IsKeyDown(Keys.D) ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1 ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1)
                {
                    ((TankGame)Game).Components.Remove(hintScreen);
                    startScreen.clearScreen();
                    ChangeGameState(GameState.PLAYER1);
                    doThings();
                }
            }

            if (((TankGame)Game).gameRunning && ((TankGame)Game).currentTank.moveLimit <= 1.5 && ((TankGame)Game).turnsTaken == 0 && hasShown)
            {
                ChangeGameState(GameState.POWERUPHINT);
                powerUpHintScreen = new PowerUpHint((TankGame)Game);
                ((TankGame)Game).Components.Add(powerUpHintScreen);
                hasShown = false; 
            }

            if (currentState == GameState.POWERUPHINT)
            {
                if (((TankGame)Game).currentTank.moveLimit <= 0.5 || Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    ((TankGame)Game).Components.Remove(powerUpHintScreen);
                    ChangeGameState(GameState.PLAYER1);
                    startScreen.clearScreen();
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER1 || currentState == GameState.START)
            {
                if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER2)
            {
                if (GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.END && gameOverShown)
            {
                gameOverScreen = new GameOverScreen((TankGame)Game);
                //Music ----------------------------------------
                ((TankGame)Game).Components.Add(gameOverScreen);
                if (((TankGame)Game).soundManager.backgroundPlaying)
                    ((TankGame)Game).soundManager.stopBackground();
                if (!((TankGame)Game).soundManager.endingPlaying)
                    ((TankGame)Game).soundManager.playEnd();
                //----------------------------------------------
                gameOverShown = false; 
            }

            if (currentState == GameState.END)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.RightShift))
                {
                    ((TankGame)Game).Components.Remove(gameOverScreen);
                    gameOverScreen.stopConfetti();
                }
            }

            if (Keyboard.GetState().IsKeyUp(Keys.Enter))
            {
                enterPressed = false;
            }
            if (GamePad.GetState(PlayerIndex.One).IsButtonUp(Buttons.A))
                aPressed = false;

            base.Update(gameTime);
        }
Exemple #2
0
        public override void Update(GameTime gameTime)
        {
            if (currentState == GameState.START)
            {
                gameOverShown = true;
                startScreen.SetData(GameState.START);
                currentState = GameState.START;
                //Music-------------------------------------------
                if (((TankGame)Game).soundManager.endingPlaying)
                {
                    ((TankGame)Game).soundManager.stopEnd();
                }
                if (!((TankGame)Game).soundManager.introPlaying)
                {
                    ((TankGame)Game).soundManager.playIntro();
                }
                //------------------------------------------------
            }

            if ((Keyboard.GetState().IsKeyDown(Keys.Enter) && !enterPressed) || GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A))
            {
                if (currentState == GameState.START)
                {
                    ChangeGameState(GameState.MOVEHINT);
                    hintScreen = new MoveHintScreen((TankGame)Game);
                    ((TankGame)Game).noDebug();
                    //Music---------------------------------------------
                    if (((TankGame)Game).soundManager.introPlaying)
                    {
                        ((TankGame)Game).soundManager.stopIntro();
                    }
                    if (!((TankGame)Game).soundManager.backgroundPlaying)
                    {
                        ((TankGame)Game).soundManager.playBackground();
                    }
                    //--------------------------------------------------
                    ((TankGame)Game).Components.Add(hintScreen);
                }
            }

            if ((Keyboard.GetState().IsKeyDown(Keys.Z)) && !debugPressed)
            {
                ChangeGameState(GameState.PLAYER1);
                debugPressed = true;
                ((TankGame)Game).startDebug();
            }

            if (currentState == GameState.MOVEHINT)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.A) ||
                    Keyboard.GetState().IsKeyDown(Keys.D) ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1 ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1)
                {
                    ((TankGame)Game).Components.Remove(hintScreen);
                    startScreen.clearScreen();
                    ChangeGameState(GameState.PLAYER1);
                    doThings();
                }
            }

            if (((TankGame)Game).gameRunning && ((TankGame)Game).currentTank.moveLimit <= 1.5 && ((TankGame)Game).turnsTaken == 0 && hasShown)
            {
                ChangeGameState(GameState.POWERUPHINT);
                powerUpHintScreen = new PowerUpHint((TankGame)Game);
                ((TankGame)Game).Components.Add(powerUpHintScreen);
                hasShown = false;
            }

            if (currentState == GameState.POWERUPHINT)
            {
                if (((TankGame)Game).currentTank.moveLimit <= 0.5 || Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    ((TankGame)Game).Components.Remove(powerUpHintScreen);
                    ChangeGameState(GameState.PLAYER1);
                    startScreen.clearScreen();
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER1 || currentState == GameState.START)
            {
                if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER2)
            {
                if (GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.END && gameOverShown)
            {
                gameOverScreen = new GameOverScreen((TankGame)Game);
                //Music ----------------------------------------
                ((TankGame)Game).Components.Add(gameOverScreen);
                if (((TankGame)Game).soundManager.backgroundPlaying)
                {
                    ((TankGame)Game).soundManager.stopBackground();
                }
                if (!((TankGame)Game).soundManager.endingPlaying)
                {
                    ((TankGame)Game).soundManager.playEnd();
                }
                //----------------------------------------------
                gameOverShown = false;
            }

            if (currentState == GameState.END)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.RightShift))
                {
                    ((TankGame)Game).Components.Remove(gameOverScreen);
                    gameOverScreen.stopConfetti();
                }
            }

            if (Keyboard.GetState().IsKeyUp(Keys.Enter))
            {
                enterPressed = false;
            }
            if (GamePad.GetState(PlayerIndex.One).IsButtonUp(Buttons.A))
            {
                aPressed = false;
            }

            base.Update(gameTime);
        }