示例#1
0
        /// <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 ((!IsActive && Loader != null) || locked)
            {
                base.Update(gameTime);
                return;
            }

            Input.Update(gameTime, false);
            MediaSystem.Update(gameTime, Program.Game.IsActive);

            if (Loading)
            {
                IsFixedTimeStep = true;
                Loader l = loadingScreen.Update(gameTime);
                if (l != null)
                {
                    IsFixedTimeStep = false;
                    Loader          = l;
                    loadingScreen   = null;
                    Loading         = false;
                    MenuHandler.Create(Loader);
                    createActors();
                }
            }
            else
            {
                GameState statePrior = GameManager.State;
                MenuHandler.Update(gameTime);
                bool stateChanged = GameManager.State != statePrior;

                if (GameManager.State == GameState.Running)
                {
                    IsMouseVisible = false;
                    if ((Input.CheckKeyboardJustPressed(Keys.Escape) ||
                         Input.CheckXboxJustPressed(Buttons.Start)) && !stateChanged)
                    {
                        //MediaSystem.PlaySoundEffect(SFXOptions.Pause);
                        GameManager.State = GameState.Paused;
                    }
                    else
                    {
                        GameManager.Space.Update((float)(gameTime.ElapsedGameTime.TotalSeconds));
                        RenderingDevice.Update(gameTime);

                        Player.Update(gameTime);
                        SubtitleBox.Update();
                        august.Update(gameTime);
                        foreach (Actor a in actorList)
                        {
                            a.Update(gameTime);
                        }

                        if (IsActive)
                        {
                            Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
                        }
                    }
                }
                else if (GameManager.State != GameState.Ending && GameManager.State != GameState.GameOver && GameManager.State != GameState.Menuing_Lev)
                {
                    IsMouseVisible = true;
                }
            }

            base.Update(gameTime);
        }