public void OnClick(string element) { if (element == "play")//PlayButton { gameState = GameState.LevelSelect; } if (element == "nameBtn")//EnterName button { gameState = GameState.enterName; } if (element == "done")//Done button { gameState = GameState.mainMenu; } if (element == "Level1")//Level1 button { levelLoader.CreateLevel(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level1.level", sprites); master.recieveLevel(levelLoader.returnLevel()); gameState = GameState.inGame; master.IsMouseVisible = false; } if (element == "Level2")//Level2 button { levelLoader.CreateLevel(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level2.level", sprites); master.recieveLevel(levelLoader.returnLevel()); gameState = GameState.inGame; master.IsMouseVisible = false; } if (element == "Level2")//Level2 button { levelLoader.CreateLevel(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level3.level", sprites); master.recieveLevel(levelLoader.returnLevel()); gameState = GameState.inGame; master.IsMouseVisible = false; } }
/// <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 (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.Q)) { levelLoader.CreateLevel(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level1.level", sprites); CurrentLevel = levelLoader.returnLevel(); } //Switch between fullscreen using left or right alt and enter if ((Keyboard.GetState().IsKeyDown(Keys.RightAlt) || Keyboard.GetState().IsKeyDown(Keys.LeftAlt)) && Keyboard.GetState().IsKeyDown(Keys.Enter)) { if (fullscreen) { graphics.IsFullScreen = false; graphics.ApplyChanges(); fullscreen = false; } else { graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 800; graphics.IsFullScreen = true; graphics.ApplyChanges(); fullscreen = true; } } if (CurrentLevel != null) { if (CurrentLevel.players.Count <= 1) { if (File.Exists(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level" + levelNum + ".level")) { levelLoader.CreateLevel(System.Reflection.Assembly.GetExecutingAssembly().Location + "../../Content/Levels/level" + levelNum + ".level", sprites); CurrentLevel = levelLoader.returnLevel(); levelNum++; } else { // menu.gameState = MainMenu.GameState.mainMenu; levelNum = 1; } } } levelEditor.checkState(this, CurrentLevel, sprites); menu.Update(); //levelEditor.checkState(this, CurrentLevel, sprites); // TODO: Add your update logic here //Controls playerOneTest = new Controls(); camera.camUpdate(gameTime, CurrentLevel); updatePlayers(gameTime); if (listLoaded == true) { clean(); } base.Update(gameTime); }