protected override void Update(GameTime gameTime) { timeCounter += gameTime.ElapsedGameTime.Milliseconds; // updates per second updateTimeCounter += gameTime.ElapsedGameTime.Milliseconds; ++updates; if (updateTimeCounter >= 1000) { drawUpdates = updates; updates = 0; updateTimeCounter -= 1000; } //// DON'T TOUCH THIS//// keyboard = Keyboard.GetState(); lastMouseState = mouseState; mouseState = Mouse.GetState(); //mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view); //camera.Update(gameTime, gameTime.ElapsedGameTime.Milliseconds, mouseState); //view = camera.View; //map.update(gameTime, gameTime.ElapsedGameTime.Milliseconds); ////// DON'T TOUCH THIS//// //indexOfMiddleHexagon = Vars_Func.gridColision(camera.Target, planeLength, hexagonSideLength); //Vector2 mouseover = Vars_Func.gridColision(mousePosition, planeLength, hexagonSideLength); //Vars_Func.resetHexagonColors(map); //wavecontroller.update(gameTime, map); //Interaction.Update(gameTime, map, mouseover, mouseState, lastMouseState, keyboard); //GUI.update(gameTime, map, mouseState); if (Interaction.GameState == Vars_Func.GameState.GameOver) { gamestate = Vars_Func.GameState.GameOver; } switch (gamestate) { #region Startmenu case Vars_Func.GameState.StartMenu: StartMenu_GUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (StartMenu_GUI.getGUI_Button() != null && StartMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton) { gamestate = Vars_Func.GameState.MainMenu; timeCounter = 0; } } break; #endregion #region Mainmenu case Vars_Func.GameState.MainMenu: MainMenu_GUI.update(gameTime, mouseState, keyboard); Highscore_GUI.restGUI(); Setting_GUI.restGUI(); GameOver_GUI.restGUI(); IntroMenu_GUI.restGUI(); showIngameMenu = false; if (MainMenu_GUI.getGUI_Button() != null) { if (timeCounter > minDelayTime) { switch (MainMenu_GUI.getGUI_Button().Typ) { case Vars_Func.GUI_Typ.NewGameButton: reinitialize(); //gamestate = Vars_Func.GameState.Ingame; gamestate = Vars_Func.GameState.Intro; timeCounter = 0; //MainMenu_GUI.restGUI(); break; case Vars_Func.GUI_Typ.SettingsButton: gamestate = Vars_Func.GameState.Settings; timeCounter = 0; break; case Vars_Func.GUI_Typ.HighScoreButton: gamestate = Vars_Func.GameState.Highscore; timeCounter = 0; break; case Vars_Func.GUI_Typ.QuitButton: timeCounter = 0; this.Exit(); break; default: break; } } } break; #endregion #region Ingame case Vars_Func.GameState.Ingame: MainMenu_GUI.restGUI(); Setting_GUI.restGUI(); Highscore_GUI.restGUI(); Confirm_GUI.restGUI(); GameOver_GUI.restGUI(); IntroMenu_GUI.restGUI(); if (keyboard.IsKeyDown(Keys.Tab) && !buttonIsPressed) { buttonIsPressed = true; showIngameMenu = !showIngameMenu; } if (!keyboard.IsKeyDown(Keys.Tab) && buttonIsPressed) { buttonIsPressed = false; } // Add ingame menu if (showIngameMenu) { IngameMenu_GUI.update(gameTime, mouseState, keyboard); if (IngameMenu_GUI.getGUI_Button() != null) { switch (IngameMenu_GUI.getGUI_Button().Typ) { case Vars_Func.GUI_Typ.NewGameButton: showIngameMenu = false; IngameMenu_GUI.restGUI(); break; case Vars_Func.GUI_Typ.SettingsButton: gamestate = Vars_Func.GameState.Settings; break; case Vars_Func.GUI_Typ.HighScoreButton: gamestate = Vars_Func.GameState.Highscore; break; case Vars_Func.GUI_Typ.StartButton: //Player.saveScore(); //reinitialize(); gamestate = Vars_Func.GameState.Confirm; break; default: break; } } } else { mousePosition = Vars_Func.mousepos(GraphicsDevice, mouseState, projection, view); camera.Update(gameTime, gameTime.ElapsedGameTime.Milliseconds, mouseState); view = camera.View; map.update(gameTime, gameTime.ElapsedGameTime.Milliseconds, this); //// DON'T TOUCH THIS//// indexOfMiddleHexagon = Vars_Func.gridColision(camera.Target, planeLength, hexagonSideLength); Vector2 mouseover = Vars_Func.gridColision(mousePosition, planeLength, hexagonSideLength); Vars_Func.resetHexagonColors(map); WaveController.update(gameTime, map); BasicGUI.update(gameTime, map, mouseState); Interaction.Update(gameTime, map, mouseover, mouseState, lastMouseState, keyboard); } break; #endregion #region Highscore case Vars_Func.GameState.Highscore: Highscore_GUI.update(gameTime, mouseState, keyboard); if (showIngameMenu) { IngameMenu_GUI.restGUI(); if (timeCounter > minDelayTime) { if (Highscore_GUI.getGUI_Button() != null && Highscore_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton) { gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } } } else { MainMenu_GUI.restGUI(); if (timeCounter > minDelayTime) { if (Highscore_GUI.getGUI_Button() != null && Highscore_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton) { gamestate = Vars_Func.GameState.MainMenu; timeCounter = 0; } } } break; #endregion #region Settings case Vars_Func.GameState.Settings: Setting_GUI.update(gameTime, mouseState, lastMouseState, keyboard); if (showIngameMenu) { IngameMenu_GUI.restGUI(); if (timeCounter > minDelayTime) { if (Setting_GUI.getGUI_Button() != null && Setting_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton) { gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } } } else { MainMenu_GUI.restGUI(); if (timeCounter > minDelayTime) { if (Setting_GUI.getGUI_Button() != null && Setting_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.StartButton) { gamestate = Vars_Func.GameState.MainMenu; timeCounter = 0; } } } break; #endregion #region Confirm case Vars_Func.GameState.Confirm: Confirm_GUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (Confirm_GUI.getGUI_Button() != null && Confirm_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton) { showIngameMenu = false; IngameMenu_GUI.restGUI(); gamestate = Vars_Func.GameState.Ingame; //showIngameMenu = false; //IngameMenu_GUI.restGUI(); //gamestate = Vars_Func.GameState.GameOver; timeCounter = 0; } if (Confirm_GUI.getGUI_Button() != null && Confirm_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { Player.saveScore(); reinitialize(); IntroMenu_GUI.createGUI(); MainMenu_GUI.createGUI(); Highscore_GUI.createGUI(); gamestate = Vars_Func.GameState.MainMenu; //gamestate = Vars_Func.GameState.InsertNameConfirm; //showIngameMenu = false; //IngameMenu_GUI.restGUI(); //gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } } break; #endregion #region GameOver case Vars_Func.GameState.GameOver: GameOver_GUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (GameOver_GUI.getGUI_Button() != null && GameOver_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton) { showIngameMenu = false; Player.saveScore(); reinitialize(); MainMenu_GUI.createGUI(); IngameMenu_GUI.restGUI(); Highscore_GUI.createGUI(); gamestate = Vars_Func.GameState.Ingame; //gamestate = Vars_Func.GameState.InserNameReset; //timeCounter = 0; } if (GameOver_GUI.getGUI_Button() != null && GameOver_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { Player.saveScore(); this.Exit(); //gamestate = Vars_Func.GameState.InserNameQuit; //timeCounter = 0; } } break; #endregion #region Intro case Vars_Func.GameState.Intro: IntroMenu_GUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (IntroMenu_GUI.getGUI_Button() != null && IntroMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.NewGameButton) { MainMenu_GUI.restGUI(); reinitialize(); Setting_GUI.ShowHelp = true; gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } if (IntroMenu_GUI.getGUI_Button() != null && IntroMenu_GUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { MainMenu_GUI.restGUI(); reinitialize(); Setting_GUI.ShowHelp = false; gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } } break; #endregion #region Insert Name After Confirm case Vars_Func.GameState.InsertNameConfirm: InsertNameGUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { //Retrun the player name string PlayerName = InsertNameGUI.getPlayerName(); //TODO: pass on to the Player class Player.saveScore(); reinitialize(); IntroMenu_GUI.createGUI(); MainMenu_GUI.createGUI(); gamestate = Vars_Func.GameState.MainMenu; timeCounter = 0; } } break; #endregion #region Insert Name Before Reset case Vars_Func.GameState.InserNameReset: InsertNameGUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { //Retrun the player name string PlayerName = InsertNameGUI.getPlayerName(); //TODO: pass on to the Player class showIngameMenu = false; Player.saveScore(); reinitialize(); MainMenu_GUI.createGUI(); IngameMenu_GUI.restGUI(); gamestate = Vars_Func.GameState.Ingame; timeCounter = 0; } } break; #endregion #region Insert Name Before Quit case Vars_Func.GameState.InserNameQuit: InsertNameGUI.update(gameTime, mouseState, keyboard); if (timeCounter > minDelayTime) { if (InsertNameGUI.getGUI_Button() != null && InsertNameGUI.getGUI_Button().Typ == Vars_Func.GUI_Typ.QuitButton) { timeCounter = 0; //Retrun the player name string PlayerName = InsertNameGUI.getPlayerName(); //TODO: pass on to the Player class Player.saveScore(); this.Exit(); } } break; #endregion default: break; } base.Update(gameTime); }