protected override void Initialize() { base.Initialize(); MainCamera = new MarioCamera(GraphicsDevice.Viewport, this); MainCameraObject = MainCamera; UI = new MarioUI(this); UI.Load(Content); finderInit.CollisionInit(); spriteBatch = new SpriteBatch(GraphicsDevice); home = new MainMenu(this); home.Load(Content); cheats = new Cheater(st, UI, this); editor = new LevelEditor(this); changer = new LevelChanger(csvFile, this, spriteBatch); GameReset = new GeneralGameCommands.ChangeLevel(this); mouse = new MouseController(this); pauser = new PauseMenu(this, spriteBatch); pauser.Load(Content); trophy = new Trophies(spriteBatch, this); trophy.Load(); RumbleHelper = new GamepadRumbleHelper(); data = new SaveDataManagement(this); keyboard = new KeyBoard(this); gamepad = new Gamepad(this); }
protected override void Update(GameTime gameTime) { if (atMainMenu) { home.Update(); } else { pauser.Update(); trophy.Update(); if (!pauser.isPaused()) { cheats.Update(); if (Mario.Health() == MarioStateMachine.MarioHealth.Dead) { countToRestart--; } if (countToRestart == 0) { countToRestart = 100; changer.changeLevel(); LevelChanger.SetBGMusic(curLevel); } if (EnableControls) { keyboard.Update(gameTime); gamepad.Update(gameTime); mouse.Update(gameTime); RumbleHelper.Update(gameTime); } if (!changingLevel) { Mario.Update(gameTime); parser.Update(); } MainCamera.Update(Mario); load.Update(); UI.Update(gameTime); if (!timerEnabled) { UI.StopTimer(); } parser.ToggleCastle(toggleCastle); base.Update(gameTime); } else { pauser.Update(); if (EnableControls) { keyboard.Update(gameTime); gamepad.Update(gameTime); mouse.Update(gameTime); RumbleHelper.Update(gameTime); } } } }
protected override void Draw(GameTime gameTime) { if (atMainMenu) { home.Draw(spriteBatch, GraphicsDevice); } else { if (!(curLevel.Contains("Underground") || curLevel.Contains("Four"))) { GraphicsDevice.Clear(Color.CornflowerBlue); } else { GraphicsDevice.Clear(Color.Black); } if (!isGameOver) { GameNotOverDraw(gameTime); } else { MusicManager.Instance.StopBackgroundMusic(); parser.Draw(); Mario.Draw(spriteBatch); UI.Draw(spriteBatch); trophy.Draw(); if (delay > 150) { load.GameOver(spriteBatch); if (!soundPlayed) { MarioWorldSoundBoard.Instance.PlayGameOver(); soundPlayed = true; } else if (soundPlayed && delay > 350) { changer.changeLevel(); LevelChanger.SetBGMusic(curLevel); delay = 0; soundPlayed = false; st = new ScoreTracker(); isGameOver = false; } } delay++; } } }