Update() public method

public Update ( ) : void
return void
Esempio n. 1
0
        protected override void Update(GameTime gameTime)
        {
            debugValue = "";
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) || closeGame)
            {
                Exit();
            }

            mouseState    = Mouse.GetState();
            mousePosition = mouseState.Position.ToVector2() / 3f;       //Divided by 3 cause it has to be converted into screen-space coordinates

            if (fadeOutTimer > 0)
            {
                fadeOutTimer--;
                fadeProgress = 1f - ((float)fadeOutTimer / (float)fadeOutStartTime);
            }
            if (fadeInTimer > 0)
            {
                fadeInTimer--;
                fadeProgress = (float)fadeInTimer / (float)fadeInStartTime;
            }

            animationHandler.Update();
            musicManager.UpdateMusic();
            shaderManager.Update();
            switch (gameState)
            {
            case GameStates.GameState_Title:
                parallax.Update();
                mainUI.Update();
                //shaderManager.ActivateBlackHoleShader(0.1f, mousePosition);
                break;

            case GameStates.GameState_Playing:
                parallax.Update();

                VisualEffect[]  backgroundEffectsClone = backgroundEffects.ToArray();           //This is so that when the active list changes, the loop isn't affected
                Projectile[]    activeProjectilesClone = activeProjectiles.ToArray();
                CollisionBody[] activeEntitiesClone    = activeEntities.ToArray();
                VisualEffect[]  activeEffectsClone     = activeEffects.ToArray();
                UIObject[]      activeUIClone          = activeUI.ToArray();
                foreach (VisualEffect backgroundEffect in backgroundEffectsClone)
                {
                    backgroundEffect.Update();
                }
                foreach (Projectile projectile in activeProjectilesClone)
                {
                    projectile.Update();
                }
                foreach (CollisionBody entity in activeEntitiesClone)
                {
                    entity.Update();
                }
                foreach (VisualEffect effect in activeEffectsClone)
                {
                    effect.Update();
                }
                foreach (UIObject ui in activeUIClone)
                {
                    ui.Update();
                }

                HandleEvents();
                CheckForEvents();
                SpawnBackgroundEffects();
                SpawnEnemies();

                break;

            case GameStates.GameState_Paused:
                break;

            case GameStates.GameState_GameOver:

                if (activeEntities.Count != 0)
                {
                    backgroundEffects.Clear();
                    activeEntities.Clear();
                    activeProjectiles.Clear();
                    activeEffects.Clear();
                    activeUI.Clear();
                }
                break;
            }
        }
Esempio n. 2
0
 internal override void Update(GameTime time)
 {
     base.Update(time);
     canvas.Update(time);
 }