Beispiel #1
0
        protected override void Draw(GameTime gameTime)
        {
            //Frames per second
            frameTimeCounter += gameTime.ElapsedGameTime.Milliseconds;
            ++frames;
            if (frameTimeCounter >= 1000)
            {
                drawFrame         = frames;
                frames            = 0;
                frameTimeCounter -= 1000;
            }

            GraphicsDevice.Clear(Color.Black);
            effect.View               = camera.View;
            effect.Projection         = camera.Projection;
            effect.VertexColorEnabled = true;
            effect.CurrentTechnique.Passes[0].Apply();
            map.DrawModel(camera, indexOfMiddleHexagon, camera.Target, mapDrawWidth);

            spriteBatch.Begin();

            //if (Interaction.GameState != Vars_Func.GameState.MainMenu &&
            //    Interaction.GameState != Vars_Func.GameState.Highscore &&
            //    Interaction.GameState != Vars_Func.GameState.Tutorial)
            //{
            //    minimap.drawMinimap(spriteBatch, indexOfMiddleHexagon);
            //}
            //GUI.Draw(spriteBatch, font, mouseState, camera, map);
            //GUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
            ////spriteBatch.DrawString(font, mouseState.X.ToString() + " : " + mouseState.Y.ToString(), new Vector2(20, 200), Color.Black);
            ////spriteBatch.DrawString(font, mousePosition.X.ToString() + " : " + mousePosition.Y.ToString() + " : " + mousePosition.Z.ToString(), new Vector2(20, 220), Color.Black);
            //spriteBatch.DrawString(font, "FPS: " + drawFrame.ToString(), new Vector2(20, 240), Color.Black);
            //spriteBatch.DrawString(font, "UPS: " + drawUpdates.ToString(), new Vector2(20, 260), Color.Black);

            switch (gamestate)
            {
                #region Startmenu
            case Vars_Func.GameState.StartMenu:
                StartMenu_GUI.Draw(spriteBatch, font);
                break;

                #endregion
                #region Mainmenu
            case Vars_Func.GameState.MainMenu:
                // Draw the old one unil menu is ready
                if (!MainMenu_GUI.UpdateReady)
                {
                    StartMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Ingame
            case Vars_Func.GameState.Ingame:
                if (reinitializeDone)
                {
                    //minimap.drawMinimap(spriteBatch, indexOfMiddleHexagon);
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    //spriteBatch.DrawString(font, mouseState.X.ToString() + " : " + mouseState.Y.ToString(), new Vector2(20, 200), Color.Black);
                    //spriteBatch.DrawString(font, mousePosition.X.ToString() + " : " + mousePosition.Y.ToString() + " : " + mousePosition.Z.ToString(), new Vector2(20, 220), Color.Black);
                    //spriteBatch.DrawString(font, "FPS: " + drawFrame.ToString(), new Vector2(20, 240), Color.Black);
                    //spriteBatch.DrawString(font, "UPS: " + drawUpdates.ToString(), new Vector2(20, 260), Color.Black);

                    if (showIngameMenu)
                    {
                        if (!IngameMenu_GUI.UpdateReady)
                        {
                            //Do nothing
                        }
                        else
                        {
                            IngameMenu_GUI.Draw(spriteBatch, font);
                        }
                    }
                }
                else
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Highscore
            case Vars_Func.GameState.Highscore:
                if (showIngameMenu)
                {
                    if (!Highscore_GUI.UpdateReady)
                    {
                        IngameMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Highscore_GUI.Draw(spriteBatch, font);
                    }
                }
                else
                {
                    if (!Highscore_GUI.UpdateReady)
                    {
                        MainMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Highscore_GUI.Draw(spriteBatch, font);
                    }
                }
                break;

                #endregion
                #region Settings
            case Vars_Func.GameState.Settings:
                if (showIngameMenu)
                {
                    if (!Setting_GUI.UpdateReady)
                    {
                        IngameMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Setting_GUI.Draw(spriteBatch, font);
                        if (Setting_GUI.UseFullscreen && !this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                        else if (!Setting_GUI.UseFullscreen && this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                    }
                }
                else
                {
                    if (!Setting_GUI.UpdateReady)
                    {
                        MainMenu_GUI.Draw(spriteBatch, font);
                    }
                    else
                    {
                        Setting_GUI.Draw(spriteBatch, font);
                        if (Setting_GUI.UseFullscreen && !this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                        else if (!Setting_GUI.UseFullscreen && this.graphics.IsFullScreen)
                        {
                            this.graphics.ToggleFullScreen();
                        }
                    }
                }
                break;

                #endregion
                #region Confirm
            case Vars_Func.GameState.Confirm:
                if (!Confirm_GUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    IngameMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    Confirm_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region GameOver
            case Vars_Func.GameState.GameOver:
                if (!GameOver_GUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }

                break;

                #endregion
                #region Intro
            case Vars_Func.GameState.Intro:
                if (!IntroMenu_GUI.UpdateReady)
                {
                    MainMenu_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    IntroMenu_GUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name After Confirm
            case Vars_Func.GameState.InsertNameConfirm:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    Confirm_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name Before Reset
            case Vars_Func.GameState.InserNameReset:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
                #region Insert Name Before Quit
            case Vars_Func.GameState.InserNameQuit:
                if (!InsertNameGUI.UpdateReady)
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    GameOver_GUI.Draw(spriteBatch, font);
                }
                else
                {
                    BasicGUI.Draw(spriteBatch, font, minimap, indexOfMiddleHexagon);
                    InsertNameGUI.Draw(spriteBatch, font);
                }
                break;

                #endregion
            default:
                break;
            }
            spriteBatch.Draw(Vars_Func.getCursor(), new Vector2(mouseState.X, mouseState.Y), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }