Beispiel #1
0
 /// <summary>
 /// Loads the title Screen
 /// </summary>
 /// <param name="playerIndex">current Player Index</param>
 private void loadTitleScreen(PlayerIndex playerIndex)
 {
     ScreenManager.RemoveScreen(this);
     LoadingScreen.Load(ScreenManager, false, playerIndex,
                        new TitleScreen());
 }
Beispiel #2
0
        /// <summary>
        /// Updates the state of the game.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (IsActive)
            {
                //play background music
                if (MediaPlayer.State != MediaState.Playing)
                {
                    SoundManager.PlayMusic("Sound/Music/" + map.AmbientAudio);
                }

                // Look up inputs for the specified player profile.
                keyboardState = Keyboard.GetState(currentPlayerIndex);
                gamePadState  = GamePad.GetState(currentPlayerIndex);

                if (gamePadState.IsConnected)
                {
                    // update the camera using the gamepad as input
                    camera.Update(
                        (float)gameTime.ElapsedGameTime.TotalSeconds,
                        gamePadState,
                        map);
                }
                else
                {
                    // update the camera using the keyboard as input
                    camera.Update(
                        (float)gameTime.ElapsedGameTime.TotalSeconds,
                        keyboardState,
                        map);
                }

                map.Actors.AnimateActors(camera, gameTime);

                //update the renderer
                renderer.Update(map, camera);

                // check if a door was hit
                if (camera.DoorHit)
                {
                    // TODO: optimize this crap!!!
                    currentSecret = map.Secrets.getCurrentSecret(map, renderer.mapX, renderer.mapY);
                    if (currentSecret != null)
                    {
                        currentSecret.gameTime = gameTime;
                    }

                    currentDoor = map.Doors.getCurrentDoor(map, renderer.mapX, renderer.mapY);
                    if (currentDoor != null)
                    {
                        currentDoor.gameTime = gameTime;
                    }
                }
                else
                {
                    currentDoor = null;
                }
            }



            // If we are in a network game, check if we should return to the lobby.
            if ((networkSession != null) && !IsExiting)
            {
                if (networkSession.SessionState == NetworkSessionState.Lobby)
                {
                    LoadingScreen.Load(ScreenManager, false, null,
                                       new LobbyScreen(networkSession));
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to quit" message box. This uses the loading screen to
 /// transition from the game back to the main menu screen.
 /// </summary>
 void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new MainMenuScreen());
 }