Exemple #1
0
        public static void DrawHUD(GameTime gameTime)
        {
            if (Globals.DisplayHUD)
            {
                foreach (RacerHuman h_racer in humanRacers)
                {
                    BeatShift.graphics.GraphicsDevice.Viewport = h_racer.localCamera.Viewport;

                    //if(Physics.Visible)
                    //    Physics.Draw(gameTime);
                    //BeatShift.graphics.GraphicsDevice.Viewport = h_racer.localCamera.Viewport;
                    BeatShift.spriteBatch.Begin();
                    HeadsUpDisplay.DrawHUD(h_racer.localCamera, h_racer, gameTime);

                    //If testing AI through a human racer, draw AI debug HUD
                    if (AiInputManager.testAI && (h_racer.racingControls != null) && (h_racer.racingControls.chosenInput != null) && h_racer.racingControls.chosenInput.GetType().Equals(typeof(AiInputManager)))
                    {
                        ((AiInputManager)h_racer.racingControls.chosenInput).DrawAiHUD(h_racer.localCamera, gameTime);
                    }

                    BeatShift.spriteBatch.End();
                }

                BeatShift.spriteBatch.Begin();

                BeatShift.singleton.GraphicsDevice.Viewport = Viewports.fullViewport;

                if (humanRacers.Count == 2)
                {
                    HeadsUpDisplay.DrawSplitBarsTwoPlayer();
                }
                else if (humanRacers.Count == 3)
                {
                    HeadsUpDisplay.DrawSplitBarsThreePlayer();
                }
                else if (humanRacers.Count == 4)
                {
                    HeadsUpDisplay.DrawSplitBarsFourPlayer();
                    if (Race.isPrimed)
                    {
                        BeatShift.spriteBatch.Draw(GameTextures.Start, new Vector2(BeatShift.graphics.GraphicsDevice.Viewport.Width / 2 - GameTextures.Start.Width / 2, 0), Color.White);
                    }
                }
                BeatShift.spriteBatch.End();
            }
            else
            {
                BeatShift.singleton.GraphicsDevice.Viewport = Viewports.fullViewport;
            }
        }
Exemple #2
0
        public static void Update(GameTime gameTime)
        {
#if DEBUG
            DebugSystem.Instance.TimeRuler.StartFrame();
#endif
            using (new ProfileSection("Background", Color.Blue))
            {
                // Check to see if the user has paused or unpaused
                BeatShift.bgm.Update();
                // Task music = Parallel.Start();
                if (currentState == GameState.LocalGame || currentState == GameState.NetworkedGame)
                {
                    checkPauseKey(gameTime);
                }

                checkPauseGuide();

#if XBOX
                checkControllers(gameTime);
#endif

                // If the user hasn't paused, Update normally

                LiveServices.Update(gameTime);

                //Update mainGameInput
                if (!LiveServices.GuideIsVisible())
                {
                    mainGameinput.Update(gameTime);
                }
            }

            if (!pausedForGuide)
            {
                MenuManager.Update(gameTime);
            }

            if (!paused)
            {
                Boolean raceUpdated = false;
                if (GameLoop.getCurrentState() == GameState.LocalGame)
                {
                    //IWork pudate = new IWork();
                    //particles = Parallel.Start(()=>BeatShift.particleManager.UpdateAllParticleSystems((float)gameTime.ElapsedGameTime.TotalSeconds));
                    //BeatShift.particleManager.UpdateAllParticleSystems((float)gameTime.ElapsedGameTime.TotalSeconds);
                }

                //Update all managed timers.
                RunningTimer.Update(gameTime);

                if (BeatShift.shipSelect.Enabled)
                {
                    BeatShift.shipSelect.Update(gameTime);
                }

                //if (networkedGame.Enabled) networkedGame.Update(gameTime);

                using (new ProfileSection("Physics", Color.Red))
                {
                    if (Physics.Enabled)
                    {
                        Physics.Update(gameTime);
                    }
                }


                using (new ProfileSection("Race", Color.Yellow))
                {
                    if (Race.Enabled)
                    {
                        Race.Update(gameTime);
                        raceUpdated = true;
                        HeadsUpDisplay.Update(gameTime);
                    }
                }


                //What??
                if (MapManager.Enabled && !raceUpdated)
                {
                    Race.Update(gameTime);
                }
            }


            //full screen option
#if WINDOWS
            //F4 press triggers fullscreen
            if (Keyboard.GetState().IsKeyDown(Keys.F4))
            {
                wasF4pressed = true;
            }
            if (wasF4pressed)
            {
                if (Keyboard.GetState().IsKeyUp(Keys.F4))
                {
                    wasF4pressed = false;
                    BeatShift.graphics.ToggleFullScreen();
                }
            }
#endif

#if DEBUG
            //Insert repeats last debug command if debug window shut
            if (DebugSystem.Instance.DebugCommandUI.isClosed())
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Insert))
                {
                    wasInsertPressed = true;
                }

                if (wasInsertPressed)
                {
                    if (Keyboard.GetState().IsKeyUp(Keys.Insert))
                    {
                        wasInsertPressed = false;
                        DebugSystem.Instance.DebugCommandUI.RepeatLastCommand();
                    }
                }
            }
#endif
            //music.Wait();


            BeatShift.engine.Update();
        }