protected override void Update(GameTime gameTime) { MouseAdapter.Update(gameTime); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { GameState = GameStates.MainMenu; } if (GameState == GameStates.MainMenu) { foreach (var child in ((UIMenu)mainMenu.Child).Children) { if (child.Contains(MouseAdapter.Position)) { child.Select(); } else { child.Deselect(); } } if (MouseAdapter.ConsumeLeftClick) { mainMenu.Execute(); } } else if (GameState != GameStates.End) { if (MouseAdapter.ScrollUp) { camera.Zoom += 0.5f; } if (MouseAdapter.ScrollDown) { camera.Zoom -= 0.5f; } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { camera.MoveCamera(new Vector2(-3, 0), true); } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { camera.MoveCamera(new Vector2(3, 0), true); } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { camera.MoveCamera(new Vector2(0, -3), true); } if (Keyboard.GetState().IsKeyDown(Keys.Down)) { camera.MoveCamera(new Vector2(0, 3), true); } if (MouseAdapter.Position.X > 420 && MouseAdapter.Position.X < 1500) //Mouse inside of game window { currentLevel.MouseOver(camera.ScreenToWorld(MouseAdapter.Position.ToVector2()).ToPoint(), MouseAdapter.Position); if (MouseAdapter.ConsumeLeftClick) { currentLevel.LeftClick(camera.ScreenToWorld(MouseAdapter.Position.ToVector2()).ToPoint(), MouseAdapter.Position); } } else { currentLevel.MouseOver(new Point(-10000, -10000), MouseAdapter.Position); } currentLevel.Update(gameTime); if (currentLevel.LevelFinished) { levelIndex++; if (levelIndex < levels.Length) { currentLevel.Stop(); currentLevel = levels[levelIndex]; GameState = GameStates.Playing; currentLevel.Start(); } else if (!currentLevel.IsGameOver) { currentLevel.GameOver(); } } else if (currentLevel.LevelLost) { currentLevel.Start(); } } else { currentLevel.Update(gameTime); if (currentLevel != null && GameState == GameStates.End) { currentLevel.Stop(); GameState = GameStates.MainMenu; levelIndex = 0; currentLevel = levels[levelIndex]; } } base.Update(gameTime); }