/// <summary> /// A helper method that will initialize the main menu whenever it is called /// </summary> public void SwitchToMainMenu() { Soundtrack.Stop(); IsMouseVisible = true; CurrentState = MainGameState.Menu; int height = GraphicsDevice.Viewport.Height; int width = GraphicsDevice.Viewport.Width; buttons = new Button[2]; Texture2D startButton = allTextures["StartButton"]; buttons[0] = new Button(startButton, "StartButton", new Rectangle(width / 2 - startButton.Width / 2, height * 6 / 10 - startButton.Height / 2, startButton.Width, startButton.Height)); Texture2D exitButton = allTextures["ExitButton"]; buttons[1] = new Button(exitButton, "ExitButton", new Rectangle(width / 2 - exitButton.Width / 2, height * 3 / 4 - exitButton.Height / 2, exitButton.Width, exitButton.Height)); indexActiveButton = 0; }
/// <summary> /// A helper method that initializes the game over state when called /// </summary> public void SwitchToGameOver() { Soundtrack.Stop(); laugh.Play(); IsMouseVisible = true; CurrentState = MainGameState.GameOver; int height = GraphicsDevice.Viewport.Height; int width = GraphicsDevice.Viewport.Width; Texture2D background = allTextures["GameOverBackground"]; // scale the buttons to the size of the screen float scale = (float)height / (float)background.Height; buttons = new Button[2]; Texture2D retry = allTextures["GameOverRetry"]; Texture2D exit = allTextures["GameOverExit"]; buttons[0] = new Button(retry, "Retry", new Rectangle((int)(width / 2 - (scale * retry.Width) / 2), (int)(.65 * height), (int)(retry.Width * scale), (int)(retry.Height * scale))); buttons[1] = new Button(exit, "Exit", new Rectangle((int)(width / 2 - (scale * exit.Width) / 2), (int)(.8 * height), (int)(exit.Width * scale), (int)(exit.Height * scale))); indexActiveButton = 0; }
/// <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); // Set up animation variables fps = 30.0; secondsPerFrame = 1.0f / fps; // Import levels //levelOne.Import(); // Add all necessary textures to the dictionary allTextures.Add("Floor", Content.Load <Texture2D>("missingtexture")); allTextures.Add("PenPen", Content.Load <Texture2D>("PenPen")); allTextures.Add("PenPenWalking", Content.Load <Texture2D>("PenPenWalking")); allTextures.Add("missingtexture", Content.Load <Texture2D>("missingtexture")); allTextures.Add("Enemy", Content.Load <Texture2D>("Penguin")); allTextures.Add("Menu", Content.Load <Texture2D>("Menu")); allTextures.Add("StartButton", Content.Load <Texture2D>("StartButton")); allTextures.Add("ExitButton", Content.Load <Texture2D>("ExitButton")); allTextures.Add("PauseMenu", Content.Load <Texture2D>("PauseMenu")); allTextures.Add("ResumeButton", Content.Load <Texture2D>("ResumeButton")); allTextures.Add("MainMenuButton", Content.Load <Texture2D>("MainMenuButton")); allTextures.Add("GameOverBackground", Content.Load <Texture2D>("GameOverBackground")); allTextures.Add("GameOverRetry", Content.Load <Texture2D>("GameOverRetry")); allTextures.Add("GameOverExit", Content.Load <Texture2D>("GameOverExit")); allTextures.Add("Heart", Content.Load <Texture2D>("Heart")); allTextures.Add("Button", Content.Load <Texture2D>("Button")); allTextures.Add("Blank", Content.Load <Texture2D>("Blank")); allTextures.Add("ParkaDude", Content.Load <Texture2D>("ParkaDude")); allTextures.Add("Boss", Content.Load <Texture2D>("Boss")); allTextures.Add("Chain", Content.Load <Texture2D>("Chain")); allTextures.Add("Mace", Content.Load <Texture2D>("Mace")); allTextures.Add("Victory", Content.Load <Texture2D>("Victory")); allTextures.Add("Background", Content.Load <Texture2D>("Background")); // Load tiles systemmatically // BrickWall for (int i = 0; i < 16; i++) { allTextures.Add("BrickWall" + i, Content.Load <Texture2D>("Tiles/BrickWall" + i)); } // BrickWallBlue for (int i = 0; i < 16; i++) { allTextures.Add("BrickWallBlue" + i, Content.Load <Texture2D>("Tiles/BrickWallBlue" + i)); } // BrickWallRed for (int i = 0; i < 16; i++) { allTextures.Add("BrickWallRed" + i, Content.Load <Texture2D>("Tiles/BrickWallRed" + i)); } // holder for (int i = 0; i < 16; i++) { allTextures.Add("holder" + i, Content.Load <Texture2D>("Tiles/holder" + i)); } // temp for (int i = 0; i < 16; i++) { allTextures.Add("temp" + i, Content.Load <Texture2D>("Tiles/temp" + i)); } // Walls for (int i = 0; i < 16; i++) { allTextures.Add("Walls" + i, Content.Load <Texture2D>("Tiles/Walls" + i)); } // WallsGreen for (int i = 0; i < 16; i++) { allTextures.Add("WallsGreen" + i, Content.Load <Texture2D>("Tiles/WallsGreen" + i)); } // WallsRed for (int i = 0; i < 16; i++) { allTextures.Add("WallsRed" + i, Content.Load <Texture2D>("Tiles/WallsRed" + i)); } // Portal for (int i = 0; i < 16; i++) { allTextures.Add("Portal" + i, Content.Load <Texture2D>("Tiles/Portal" + i)); } // Load maps maps.Add("Map1", new World(allTextures, "Map1", "Content/Map1.map")); maps.Add("RedMap", new World(allTextures, "RedMap", "Content/RedMap.map")); maps.Add("BlueMap", new World(allTextures, "BlueMap", "Content/BlueMap.map")); maps.Add("PathTest", new World(allTextures, "PathTest", "Content/PathTest.map")); maps.Add("Tutorial1", new World(allTextures, "Tutorial1", "Content/Tutorial1.map")); maps.Add("Tutorial2", new World(allTextures, "Tutorial2", "Content/Tutorial2.map")); maps.Add("Actual1", new World(allTextures, "Actual1", "Content/Actual1.map")); maps.Add("Actual2", new World(allTextures, "Actual2", "Content/Actual2.map")); maps.Add("Actual3", new World(allTextures, "Actual3", "Content/Actual3.map")); maps.Add("Actual4", new World(allTextures, "Actual4", "Content/Actual4.map")); maps.Add("Actual5", new World(allTextures, "Actual5", "Content/Actual5.map")); maps.Add("Actual6", new World(allTextures, "Actual6", "Content/Actual6.map")); maps.Add("BossMap", new World(allTextures, "BossMap", "Content/BossMap.map")); currentWorld = maps["Tutorial1"]; World.Current = currentWorld; //levelOne = new World(allTextures, "Level One", "level1.txt"); // Change the game to fullscreen and start the main menu graphics.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; graphics.IsFullScreen = true; graphics.ApplyChanges(); currentBoss = new Boss(allTextures["Blank"], allTextures["Boss"], allTextures["Chain"], allTextures["Mace"], (int)maps["BossMap"].WorldMaxX / 2 - 128, (int)maps["BossMap"].WorldMaxY / 2 - 128, 256, 256); SwitchToMainMenu(); // NOTE: ElecTown is an arrangement of a track from Megaman Battle Network 4 by Capcom. Cannot be used in the main game Soundtrack elecTown = new Soundtrack(Content.Load <Song>("Electown"), 150, 16, 4); elecTown.SetLead(Content.Load <Song>("Electown_Lead"), 150, 4, 4); // tracks.Add("Electown", elecTown); laugh = Content.Load <SoundEffect>("Laugh"); // currentTrack = elecTown; // Sync in-game objects with their dictionary textures // EX: testEnemy.LoadTexture(allTextures["missingtexture"]); }