/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); #region Load Textures MarioSpriteFactory.Instance.LoadAllTextures(Content); EnemySpriteFactory.Instance.LoadAllTextures(Content); ItemSpriteFactory.Instance.LoadAllTextures(Content); BlockSpriteFactory.Instance.LoadAllTextures(Content); FireballSpriteFactory.Instance.LoadAllTextures(Content); BackgroundSpriteFactory.Instance.LoadAllTextures(Content); PipeSpriteFactory.Instance.LoadAllTextures(Content); SoundManager.Instance.LoadAllSounds(Content); TextSpriteFactory.Instance.LoadAllTextures(Content); #endregion Vector2 location = new Vector2(50, 200); Mario = new MarioObject(location); objectManager = new GameObjectManager(this, Mario); gamedata = new GameData(objectManager); camera1 = new Camera(); Camera.LimitationList.Add(3600); camera2 = new Camera2D(GraphicsDevice.Viewport); blackbackground = BackgroundSpriteFactory.Instance.CreateBlackBackgroundSprite(); LevelLoader loader = new LevelLoader(objectManager, Mario); loader.Load(); keyboard = new KeyboardControls(this, Mario); gamepad = new GamePadControls(this, Mario); }
public void LevelReset() { Vector2 restartPoint = GameObjectManager.restartPoint; spriteBatch = new SpriteBatch(GraphicsDevice); #region Load Textures MarioSpriteFactory.Instance.LoadAllTextures(Content); EnemySpriteFactory.Instance.LoadAllTextures(Content); ItemSpriteFactory.Instance.LoadAllTextures(Content); BlockSpriteFactory.Instance.LoadAllTextures(Content); FireballSpriteFactory.Instance.LoadAllTextures(Content); BackgroundSpriteFactory.Instance.LoadAllTextures(Content); PipeSpriteFactory.Instance.LoadAllTextures(Content); SoundManager.Instance.LoadAllSounds(Content); TextSpriteFactory.Instance.LoadAllTextures(Content); #endregion Mario = new MarioObject(restartPoint); objectManager = new GameObjectManager(this, Mario); gamedata = new GameData(objectManager); camera1 = new Camera(); Camera.LimitationList.Add(3600); camera2 = new Camera2D(GraphicsDevice.Viewport); blackbackground = BackgroundSpriteFactory.Instance.CreateBlackBackgroundSprite(); LevelLoader loader = new LevelLoader(objectManager, Mario); loader.Load(); keyboard = new KeyboardControls(this, Mario); gamepad = new GamePadControls(this, Mario); Camera.SetCamera(new Vector2(restartPoint.X - 16 * 5, 0)); MarioInfo.ClearTimer(); MarioInfo.ResetTimer(); MarioInfo.StartTimer(); }
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; }
/// <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); }