Update() protected method

protected Update ( ) : void
return void
示例#1
0
        protected override void Update(GameTime gameTime)
        {
            Time.Update(gameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            double deltaTime = gameTime.ElapsedGameTime.TotalSeconds;

            // No game inputs taken during transitions
            if (!isTransitionning)
            {
                inputs.Update(deltaTime);
                bottomMenu.Update();
                if (currentHighScore > 0)
                {
                    score.SetText(string.Format(PROGRESSION, Score.Total, currentHighScore));
                }
                else
                {
                    score.SetText(Score.Total);
                }

                if (isInLevelEditMode)
                {
                    editor.Update();
                }
            }
            else
            {
                delayToNextLevel -= deltaTime;
                if (delayToNextLevel <= 0)
                {
                    EndTransition();
                }
            }

            base.Update(gameTime);
        }
示例#2
0
        //public ScoreEntry[] ResultScore
        //{
        //    get;
        //    private set;
        //}

        public void Update(GameTime time)
        {
            if (!IsPaused)
            {
                scene.Update(time);
            }
            soundWorld.Update(time);

            RtsCamera camera = scene.Camera;

            SoundManager.Instance.ListenerPosition = camera.Position;// PlanetEarth.GetPosition(camera.Longitude, camera.Latitude);
            // scene.Camera.ViewMatrix.TranslationValue;

            if (!IsLoaded)
            {
                bool newVal = TerrainMeshManager.Instance.IsIdle &
                              ModelManager.Instance.IsIdle &
                              TextureManager.Instance.IsIdle &
                              TreeBatchModelManager.Instance.IsIdle;

                if (newVal)
                {
                    if (--loadingCountDown < 0)
                    {
                        IsLoaded = true;
                    }
                }
                else
                {
                    if (++loadingCountDown > 100)
                    {
                        loadingCountDown = 100;
                    }
                }

                int ldop = TerrainMeshManager.Instance.GetCurrentOperationCount();
                ldop += ModelManager.Instance.GetCurrentOperationCount();
                ldop += TextureManager.Instance.GetCurrentOperationCount();
                ldop += TreeBatchModelManager.Instance.GetCurrentOperationCount();

                if (ldop > maxLoadingOp)
                {
                    maxLoadingOp = ldop;
                }

                if (maxLoadingOp > 0)
                {
                    float newPrg = 1 - ldop / (float)maxLoadingOp;
                    if (newPrg > LoadingProgress)
                    {
                        LoadingProgress = newPrg;
                    }
                }

                ingameUI.Update(time);
            }
            else
            {
                //if (gameState.CheckGameOver())
                //{
                //if (!IsOver)
                //{
                //ResultScore = gameState.GetScores();
                //ScoreEntry[] entries = gameState.GetScores();
                //ingameUI.ShowScore(entries);
                //IsOver = true;
                //}
                //}
                //else
                {
                    if (!IsPaused)
                    {
                        gameState.Update(time);
                        if (gameState.CheckGameOver())
                        {
                            ingameUI.ShowFinished();
                        }
                    }
                }

                ingameUI.Update(time);
            }
        }