/// <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(); switch (GameElements.currentState) { case GameElements._state.Quit: Exit(); break; case GameElements._state.Lobby: //CreateNewLobbySession(); GameElements.currentState = GameElements.LobbyUpdate(gameTime); break; case GameElements._state.Menu: GameElements.currentState = GameElements.MenuUpdate(gameTime); if (!alreadyExecuted) { base.Initialize(); alreadyExecuted = true; } break; case GameElements._state.Run: //put Game update here if (anka.ankaHasWon) { GameElements.currentState = GameElements._state.End; break; } alreadyExecuted = false; KeyboardState tempHandler = Keyboard.GetState(); if (tempHandler.IsKeyDown(Keys.D9)) camera.ZoomFactor *= 0.95f; if (tempHandler.IsKeyDown(Keys.D0)) camera.ZoomFactor *= 1.05f; if(tempHandler.IsKeyDown(Keys.P)) { mapEditor.SaveMap(levelLayout, "DefaultMap"); } // Turn debug on/off if (tempHandler.IsKeyDown(Keys.Z)) { if(debug == false) { debug = true; } else { debug = false; } } levelLayout.Update(gameTime, camera, debug); anka.Update(); testStudent.Update(camera); Collisions(); //update mouse input // If pageUp button is clicked while debug is on a new platforn spawns Point screenSize = GraphicsDevice.Viewport.Bounds.Size; // Gets the size of the screen camera.Update(anka, new Vector2(screenSize.X, screenSize.Y)); // Updates camera GameElements.currentState = GameElements.RunUpdate(); break; case GameElements._state.End: GameElements.currentState = GameElements.EndUpdate(gameTime); break; } base.Update(gameTime); }