Exemple #1
0
 public void UpdateLevelSelect()
 {
     if (KeyboardInput.HasBeenPressed(Keys.Left))
     {
         if (mapIndex > 1)
         {
             mapIndex--;
         }
         else if (mapIndex == 1)
         {
             mapIndex = mapAmount;
         }
     }
     if (KeyboardInput.HasBeenPressed(Keys.Right))
     {
         if (mapIndex <= mapAmount)
         {
             mapIndex++;
         }
         if (mapIndex == mapAmount + 1)
         {
             mapIndex = 1;
         }
     }
     if (KeyboardInput.HasBeenPressed(Keys.Enter))
     {
         showLevelSelectMenu = false;
         showMap             = true;
     }
     if (KeyboardInput.HasBeenPressed(Keys.Back))
     {
         showLevelSelectMenu = false;
         showMainMenu        = true;
     }
 }
Exemple #2
0
        private void UpdateMap(GameTime time)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                ExitGame = true;
            }

            //Checking if new map gets opened
            if (isLvlLoaded)
            {
                LoadLevel(lvlNr);
                isLvlLoaded = false;
            }

            map.Update(time, keyboardState);

            //Start new song if game state changed
            if (state != lastState)
            {
                MediaPlayer.Stop();
                MediaPlayer.Play(map.Song);
            }

            //Leaving Level-GameState and going back to Level Selection
            if (map.ReachedExit || KeyboardInput.HasBeenPressed(Keys.Back) || !map.Player.IsAlive)
            {
                menuScreens.showMap             = false;
                menuScreens.showLevelSelectMenu = true;
                isLvlLoaded = true;
            }
        }
Exemple #3
0
        public void UpdateGameState(GameTime time)
        {
            //Get Inputs
            keyboardState = Keyboard.GetState();
            KeyboardInput.GetInput();

            //Check which game state
            if (menuScreens.showMainMenu)
            {
                state = GameState.LandingScreen;
            }
            if (menuScreens.showLevelSelectMenu)
            {
                state = GameState.LevelSelection;
            }
            if (menuScreens.showMap)
            {
                state = GameState.Gameplay;
            }

            //Update according to game state
            switch (state)
            {
            case GameState.LandingScreen:
                UpdateLandingScreen();
                break;

            case GameState.LevelSelection:
                UpdateLevelSelection();
                break;

            case GameState.Gameplay:
                UpdateMap(time);
                break;
            }
            lvlNr = menuScreens.mapIndex;

            //Update last state (for background music)
            lastState = state;
        }