public void DeadRestartOrGameOver(GameTime gameTime) { if (level.Mario.HasDied) { deadCount++; deadCount -= level.TotalExtraLives; if (level.Mario.Live == 0) { Sounds.PlaySound(EventSoundEffects.EventSounds.GameOver); GameOverState over = new GameOverState(); gameOverState = true; KeyBoardControls = new GameOverControls(this); Feedback.Update(level, gameTime); over.Draw(_spriteBatch); } else { rest = new LevelRestartState(); rest.CheckProgress(); level = new Level(_graphics, "level.csv", Sounds); level.DifficultyMode(MenuState.Difficulty); KeyBoardControls = new KeyBoardControls(this); GamePadControls = new GamePadControls(this); level.Mario.Live -= deadCount; rest.Draw(_spriteBatch); MediaPlayer.Resume(); } } }
public void Reset() { level = new Level(_graphics, "level.csv", Sounds); menu = new MenuState(_graphics, level); menuState = true; MediaPlayer.IsRepeating = true; KeyBoardControls = new KeyBoardControls(this); GamePadControls = new GamePadControls(this); pausedState = false; gameOverState = false; deadCount = 0; level.TotalExtraLives = 0; }
public void Pause() { pausedState = !pausedState; if (pausedState) { MediaPlayer.Pause(); KeyBoardControls = new PausedGameKeyboardControls(this); } else { MediaPlayer.Resume(); KeyBoardControls = new KeyBoardControls(this); } }
// Use this for initialization void Start() { //Get main camera object this.cam = Camera.main; //Get zero'd Vector3 this.velocity = Vector3.zero; //Get the game object of the action menu and store it this.actionMenu = GameObject.FindGameObjectWithTag("actionMenu"); //Set the actionMenu to unactive this.actionMenu.SetActive(false); //Add this class to the instance variable KeyBoardControls._instance = this; //Get the list of action buttons this.buttonList = ActionMenu._instance.buttons; //initialize selectable list this.selectable = new List <GameCharacter>(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (menuState) { menu.Update(); } else { if (!pausedState && !gameOverState) { Feedback.Update(level, gameTime); level.Update(gameTime, hidden); GamePadControls.UpdateInput(); camera.Update(level.Mario.SpritePosition, Level.ScreenWidth, Level.ScreenHeight, hidden); DeadRestartOrGameOver(gameTime); WonGame(); } KeyBoardControls.UpdateInput(); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); KeyBoardControls = new KeyBoardControls(this); GamePadControls = new GamePadControls(this); }