Beispiel #1
0
        // CONSTRUCTOR:
        public GameStateManager(MonogameParty game)
        {
            this.game           = game;
            this.km             = new KeyboardManager();
            this.gameOptions    = new GameOptions();
            this.random         = new Random();
            this.debugMode      = false;
            this.clearAllStates = false;



            // Add the ** FIRST ** game states here:

            audioEngine = new S_AudioEngine(this, 0, 0);
            this.AddState(audioEngine, 0);

            State mainMenu = new S_MainMenu(this, 0, 0);

            this.AddState(mainMenu, 0);
            this.stateCount = 2;
        }
Beispiel #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++;
        }
Beispiel #3
0
        // Update:
        public override void Update(GameTime gameTime, KeyboardState ks)
        {
            base.Update(gameTime, ks);

            // Move Menu Selection Up:
            if (km.ActionPressed(KeyboardManager.action.up, KeyboardManager.playerIndex.all))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME);

                if (currentMenuItem == 1)
                {
                    currentMenuItem = 0;
                    moveGlove       = true;
                }
            }

            // Move Menu Selection Down:
            if (km.ActionPressed(KeyboardManager.action.down, KeyboardManager.playerIndex.all))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME);

                if (currentMenuItem == 0)
                {
                    currentMenuItem = 1;
                    moveGlove       = true;
                }
            }

            // Press ENTER while some menu item is highlighted:
            if (km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.all))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceHit, MGP_Constants.MENU_SFX_VOLUME + 0.15f);

                // One Player
                if (currentMenuItem == 0)
                {
                    parentManager.gameOptions.numPlayers = 1;
                    S_CharacterMenu characterMenu = new S_CharacterMenu(parentManager, 0, 0);
                    parentManager.AddStateQueue(characterMenu);
                    this.flagForDeletion = true;
                }

                //Two Players
                if (currentMenuItem == 1)
                {
                    parentManager.gameOptions.numPlayers = 2;
                    S_CharacterMenu characterMenu = new S_CharacterMenu(parentManager, 0, 0);
                    parentManager.AddStateQueue(characterMenu);
                    this.flagForDeletion = true;
                }
            }

            // Press Cancel Key: Goes back to main menu:
            if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME);

                S_MainMenu mainMenu = new S_MainMenu(parentManager, 0, 0);
                parentManager.AddStateQueue(mainMenu);
                this.flagForDeletion = true;
            }

            // Move glove
            if (moveGlove)
            {
                if (Vector2.Distance(glovePos, new Vector2(items[currentMenuItem].xPos - 60, items[currentMenuItem].yPos - 35)) < 1.0f)
                {
                    moveGlove = false;
                }
                else
                {
                    glovePos.Y = MGP_Tools.Ease(glovePos.Y, items[currentMenuItem].yPos - 35, 0.5f);
                }
            }
        } // End update
Beispiel #4
0
        // ** UPDATE **
        public override void Update(GameTime gameTime, KeyboardState ks)
        {
            base.Update(gameTime, ks);

            // Update selection / glove position:
            // PRESS DOWN
            if (km.ActionPressed(KeyboardManager.action.down, this.playerWhoPaused))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME);

                if (currentSelection < pauseItems.Count - 1)
                {
                    currentSelection++;
                }
                else
                {
                    currentSelection = 0;
                }

                // Update Glove pos:
                glove.pos = new Vector2(pauseItems[currentSelection].screenPosCentered.X - gloveAdjustX, pauseItems[currentSelection].screenPosCentered.Y - gloveAdjustY);
            }

            // PRESS UP
            if (km.ActionPressed(KeyboardManager.action.up, this.playerWhoPaused))
            {
                // SFX:
                parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME);

                if (currentSelection > 0)
                {
                    currentSelection--;
                }
                else
                {
                    currentSelection = pauseItems.Count - 1;
                }

                // Update Glove pos:
                glove.pos = new Vector2(pauseItems[currentSelection].screenPosCentered.X - gloveAdjustX, pauseItems[currentSelection].screenPosCentered.Y - gloveAdjustY);
            }

            // PRESS ENTER
            bool pressedResume = false; // false until proven true

            if (km.ActionPressed(KeyboardManager.action.select, this.playerWhoPaused))
            {
                S_Pause.pauseOptions option = (S_Pause.pauseOptions)currentSelection;

                switch (option)
                {
                case S_Pause.pauseOptions.resume:
                    pressedResume = true;
                    break;

                case S_Pause.pauseOptions.viewBoard:
                    State viewBoard = new S_CameraMode(parentManager, 0, 0, this);
                    parentManager.AddStateQueue(viewBoard);
                    break;

                case S_Pause.pauseOptions.quit:

                    // update music:
                    parentManager.audioEngine.setNextSong(MGP_Constants.music.mainMenu);
                    parentManager.audioEngine.playNextSong(20, true);

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

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

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

                    parentManager.gameOptions = new GameOptions();
                    State newMenu = new S_MainMenu(parentManager, 0, 0);
                    parentManager.AddStateQueue(newMenu);
                    this.flagForDeletion = true;
                    break;

                case S_Pause.pauseOptions.exitProgram:
                    parentManager.game.Exit();
                    break;

                default:
                    break;
                }
            }



            // UNPAUSE:
            if ((km.ActionPressed(KeyboardManager.action.pause, this.playerWhoPaused)) ||
                (km.ActionPressed(KeyboardManager.action.cancel, this.playerWhoPaused)) ||
                (pressedResume))
            {
                Console.WriteLine("Player " + ((int)this.playerWhoPaused + 1).ToString() + " resumed the game");

                // Unpause other states now:
                foreach (State s in statesToPause)
                {
                    s.active = true;
                }

                // Turn music back up:
                parentManager.audioEngine.setMusicVolume(1.0f);


                // Destroy pause menu state
                flagForDeletion = true;
                sendDelay       = 2;
            } // end UNPAUSE (if press pause/cancel button)
        }