private void ChangeScreen(MenuOption[] optionsIn) { // Play confirm sound effect. sfxUI["Confirm"].Play(); // Determine which option has been selected. for (int i = 0; i < optionsIn.Length; i++) { if (optionsIn[i].HighlightedStatus == true) { selectedOption = optionsIn[i]; break; } } // Change screen according to the selected option's function. switch (selectedOption.Function) { case "Start Game": currentState = gameState.GAMEPLAY; break; case "View Controls": currentState = gameState.CONTROLS; break; case "Quit Game": Exit(); break; case "Return to Title": currentState = gameState.TITLE; break; case "Try Again": currentState = gameState.TITLE; break; case "Quit": Exit(); break; } }
/// <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 initial gameplay state. currentState = gameState.TITLE; #region Load SFX sfxUI = Loader.ContentLoad <SoundEffect>(Content, "SFX/0 UI Sounds"); sfxGameplay = Loader.ContentLoad <SoundEffect>(Content, "SFX/1 Gameplay Sounds"); #endregion #region Load UI textures // Main menu textures. mainMenuTextures = Loader.ContentLoad <Texture2D>(Content, "Images/Screens/1 Main Menu"); // Controls screen textures. controlsTextures = Loader.ContentLoad <Texture2D>(Content, "Images/Screens/2 Controls Screen"); // Game over screen textures. gameOverTextures = Loader.ContentLoad <Texture2D>(Content, "Images/Screens/3 Game Over Screen"); #endregion // Load game font. infoFont = Content.Load <SpriteFont>("Info"); #region Create menu options - startGameOp is shared between the main menu and the controls menu. // Main startGameOp = new MenuOption(this, mainMenuTextures["4 Start Game"], new Vector2(GraphicsDevice.Viewport.Width / 2 - mainMenuTextures["4 Start Game"].Width / 2, 440), Color.White, 1, "Start Game", false); // Since "Start Game" is highlighted by default, send "true" to its method that handles whether it is highlighted or not. startGameOp.GetHighlightedStatus(true); viewControlsOp = new MenuOption(this, mainMenuTextures["5 View Controls"], new Vector2(GraphicsDevice.Viewport.Width / 2 - mainMenuTextures["5 View Controls"].Width / 2, 490), Color.White, 1, "View Controls", false); quitGameOp = new MenuOption(this, mainMenuTextures["6 Quit Game"], new Vector2(GraphicsDevice.Viewport.Width / 2 - mainMenuTextures["4 Start Game"].Width / 2, 540), Color.White, 1, "Quit Game", false); // Controls returnToTitleOp = new MenuOption(this, controlsTextures["1 Return to Title"], new Vector2(GraphicsDevice.Viewport.Width - controlsTextures["1 Return to Title"].Width, 480), Color.White, 1, "Return to Title", false); // Game Over tryAgainOp = new MenuOption(this, gameOverTextures["1 Try Again"], new Vector2(GraphicsDevice.Viewport.Width / 2 - gameOverTextures["1 Try Again"].Width / 2, 600), Color.White, 1, "Try Again", false); tryAgainOp.GetHighlightedStatus(true); quitOp = new MenuOption(this, gameOverTextures["2 Quit"], new Vector2(GraphicsDevice.Viewport.Width / 2 - gameOverTextures["1 Try Again"].Width / 2, 650), Color.White, 1, "Quit", false); // Set up arrays. mainMenuOptions = new MenuOption[3] { startGameOp, viewControlsOp, quitGameOp }; controlsOptions = new MenuOption[2] { startGameOp, returnToTitleOp }; gameOverOptions = new MenuOption[2] { tryAgainOp, quitOp }; #endregion // Create cursor and set it's initial position to that of the first main menu option. cursor = new Cursor(this, Content.Load <Texture2D>("Images/Screens/V Small Cursor"), new Vector2(startGameOp.Position.X - 30, startGameOp.Position.Y + 30), sfxUI["Navigate"]); #region Load Player. #region Load Idle Player sprites. lookingLeft = Content.Load <Texture2D>("Images/Player/Stand Left"); lookingRight = Content.Load <Texture2D>("Images/Player/Stand Right"); lookingUp = Content.Load <Texture2D>("Images/Player/Stand Up"); lookingDown = Content.Load <Texture2D>("Images/Player/Stand Down"); #endregion #region Load Movement Player sprites. movingLeft = Content.Load <Texture2D>("Images/Player/Move Left"); movingRight = Content.Load <Texture2D>("Images/Player/Move Right"); movingUp = Content.Load <Texture2D>("Images/Player/Move Up"); movingDown = Content.Load <Texture2D>("Images/Player/Move Down"); #endregion // Load the player's HUD Elements hudElements = Loader.ContentLoad <Texture2D>(Content, "Images/HUD"); // Load animated player sprite. player = new Player( this, // Game lookingDown, // Image new Vector2(300, 300), // Position Color.White, // Colour 2, // Frames hudElements); // Send these textures to the Player class. player.GetAnimations(lookingDown, lookingUp, lookingLeft, lookingRight, movingDown, movingUp, movingLeft, movingRight); #endregion // Load wall textures area1Walls = Loader.ContentLoad <Texture2D>(Content, "Images/Walls/Area1"); #region Item list setup // Load items. key1 = new Item("Silver Key", Content.Load <Texture2D>("Images/Items/Key 1"), new Vector2(400, 550), Color.White, "Opens silver doors.", "You found a silver key.", 1); key2 = new Item("Gold Key", Content.Load <Texture2D>("Images/Items/Key 2"), new Vector2(450, 540), Color.White, "Opens gold doors.", "You found a gold key.", 1); key3 = new Item("Green Key", Content.Load <Texture2D>("Images/Items/Key 3"), new Vector2(200, 300), Color.White, "Opens green doors.", "You found a green key.", 1); key4 = new Item("Blue Key", Content.Load <Texture2D>("Images/Items/Key 4"), new Vector2(100, 500), Color.White, "Opens blue doors.", "You found a blue key.", 1); // Add to the item lists for each room. room2Items.Add(key1); room3Items.Add(key2); #endregion // Rooms must be loaded first. #region Load Rooms. room1 = new Room(Content.Load <Texture2D>("Images/Floors/Wood Flooring"), room1Items, area1Walls); room2 = new Room(Content.Load <Texture2D>("Images/Floors/Wood Flooring"), room2Items, area1Walls); room3 = new Room(Content.Load <Texture2D>("Images/Floors/Wood Flooring"), room3Items, area1Walls); #endregion #region Room 1 doors. room1NorthDoor = new Door("No Key", Content.Load <Texture2D>("Images/Doors/A Open/Open Door North"), new Vector2(780, 47), Color.White, room2, true, 1); room1WestDoor = new Door(key1.Name, Content.Load <Texture2D>("Images/Doors/B Silver/Silver Door West"), new Vector2(43, 107), Color.White, room3, false, 1); // Add exits to list. room1Exits.Add(room1NorthDoor); room1Exits.Add(room1WestDoor); #endregion #region Room 2 doors. room2SouthDoor = new Door("No Key", Content.Load <Texture2D>("Images/Doors/A Open/Open Door South"), new Vector2(780, 648), Color.White, room1, true, 1); // Add exits to list. room2Exits.Add(room2SouthDoor); #endregion #region Room 3 doors. room3EastDoor = new Door(key1.Name, Content.Load <Texture2D>("Images/Doors/B Silver/Silver Door East"), new Vector2(1214, 104), Color.White, room1, false, 1); // Add exits to list. room3Exits.Add(room3EastDoor); #endregion #region Add the exit lists to their appropriate rooms. room1.GetExits(room1Exits); room2.GetExits(room2Exits); room3.GetExits(room3Exits); #endregion // Set initial room. currentRoom = room1; // TODO: use this.Content to load your game content here }