예제 #1
0
 // Listen for a pause and do so at this time
 public void ListenPause()
 {
     // Pausing while in a board state:
     if (km.ActionPressed(KeyboardManager.action.pause, KeyboardManager.playerIndex.one))
     {
         S_Pause pauseMenu = new S_Pause(parentManager, 0, 0, KeyboardManager.playerIndex.one);
         parentManager.AddStateQueue(pauseMenu);
         Console.WriteLine("Player 1 paused the game");
     }
     else if (km.ActionPressed(KeyboardManager.action.pause, KeyboardManager.playerIndex.two))
     {
         S_Pause pauseMenu = new S_Pause(parentManager, 0, 0, KeyboardManager.playerIndex.two);
         parentManager.AddStateQueue(pauseMenu);
         Console.WriteLine("Player 2 paused the game");
     }
 }
예제 #2
0
        public override void Update(GameTime gameTime, KeyboardState ks)
        {
            base.Update(gameTime, ks);
            if (timer > 60)
            {
                if (gsm.km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.all))
                {
                    // Go back to main menu
                    // update music:
                    gsm.audioEngine.setNextSong(MGP_Constants.music.mainMenu);
                    gsm.audioEngine.playNextSong(20, true);

                    // Clear all states except audio engine and this state:
                    List <State> statesToRemove = new List <State>();
                    foreach (State s in gsm.states)
                    {
                        if (s != gsm.audioEngine && s != this)
                        {
                            statesToRemove.Add(s);
                        }
                    }

                    // Remove them:
                    foreach (State s in statesToRemove)
                    {
                        gsm.RemoveState(s);
                    }

                    // Delay the update of the gameStateManager:
                    sendDelay = 2;

                    gsm.gameOptions = new GameOptions();
                    State newMenu = new S_MainMenu(gsm, 0, 0);
                    gsm.AddStateQueue(newMenu);
                    this.flagForDeletion = true;
                }
            }
            timer++;
        }