protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); //draw the correct stage switch (stage) { case Stage.Instructions: Instructions.Draw(); break; case Stage.Menu: MainMenu.Draw(); break; case Stage.Game: Game.Draw(); break; case Stage.NameEntry: NameEntryMenu.Draw(); break; case Stage.HighScores: HighScores.Draw(); break; } spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// loads all the content of the game /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Screen.spriteBatch = spriteBatch; //assigne helper variables Helper.Content = Content; Helper.graphics = graphics; Helper.SpriteBatch = spriteBatch; Helper.InputFont = Content.Load <SpriteFont>("Fonts/InputFont"); //load the game Game.LoadContent(); Game.AllLevelsComplete += score => { stage = Stage.NameEntry; NameEntryMenu.Start(score); }; //load the name entry menu NameEntryMenu.LoadContent(); NameEntryMenu.InputComplete += () => stage = Stage.Menu; //load the main menu and sign up to events MainMenu.playButtonPressed += () => { stage = Stage.Game; Game.Reset(); }; MainMenu.instructionsButtonPressed += () => stage = Stage.Instructions; MainMenu.highScoresButtonPressed += () => stage = Stage.HighScores; MainMenu.exitButtonPressed += () => Exit(); MainMenu.LoadContent(); //load high scores HighScores.BackToMenu += () => stage = Stage.Menu; HighScores.LoadContent(); //load high scores Instructions.BackToMenu += () => stage = Stage.Menu; Instructions.LoadContent(); //sign up to games back to menu event Game.BackToMenu += () => stage = Stage.Menu; }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } Helper.UpdateKeyBoard(); //update the correct stage switch (stage) { case Stage.Instructions: Instructions.Update(); break; case Stage.Menu: MainMenu.Update(); break; case Stage.Game: Game.Update(); break; case Stage.NameEntry: NameEntryMenu.Update(); break; case Stage.HighScores: HighScores.Update(); break; } base.Update(gameTime); }