Ejemplo n.º 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 (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            if (ReadyToPlay)
            {
                ReadyToPlay = false;
                state       = State.FleetMenu;
            }
            switch (state)
            {
            case State.MainMenu:
                mainMenu.Update(gameTime);
                break;

            case State.OptionsMenu:
                settingsMenu.Update(gameTime);
                break;

            case State.LoginMenu:
                loginMenu.Update(gameTime);
                break;

            case State.RegisterMenu:
                registerMenu.Update(gameTime);
                break;

            case State.DeckMenu:
                deckMenu.Update(gameTime);
                break;

            case State.GameWindow:
                gameWindow.Update(gameTime);
                break;

            case State.ShopMenu:
                shopMenu.Update(gameTime);
                break;

            case State.FleetMenu:
                fleetMenu.Update(gameTime);
                break;

            case State.CardsMenu:
                cardsMenu.Update(gameTime);
                break;
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
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 (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (ReadyToPlay)
            {
                ReadyToPlay = false;
                state       = State.FleetMenu;
            }
            switch (state)
            {
            case State.MainMenu:
                mainMenu.Update(gameTime);
                break;

            case State.OptionsMenu:
                settingsMenu.Update(gameTime);
                break;

            case State.LoginMenu:
                loginMenu.Update(gameTime);
                break;

            case State.RegisterMenu:
                registerMenu.Update(gameTime);
                break;

            case State.DeckMenu:
                deckMenu.Update(gameTime);
                break;

            case State.GameWindow:
                gameWindow.Update(gameTime);
                break;

            case State.ShopMenu:
                shopMenu.Update(gameTime);
                break;

            case State.FleetMenu:
                fleetMenu.Update(gameTime);
                break;

            case State.CardsMenu:
                cardsMenu.Update(gameTime);
                break;
            }

            var toRemove = new List <Animation>();

            animations.ForEach(p =>
            {
                if (p.Update())
                {
                    toRemove.Add(p);
                }
            });
            toRemove.ForEach(p => animations.Remove(p));
            base.Update(gameTime);
        }