Exemplo 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 (Window.ClientBounds.Width != ScreenWidth || Window.ClientBounds.Height != ScreenHeight)
            {
                ScreenWidth  = Window.ClientBounds.Width; // TODO: ON RESIZE
                ScreenHeight = Window.ClientBounds.Height;
                if (gameState != null)
                {
                    gameState.Resize(ScreenWidth, ScreenHeight);
                }
            }

            MouseControl.Update();
            KeyBindings.Update();
            if (mainMenu != null && _GlobalState == GlobalGameState.MainMenu)
            {
                Menu.Update(null, null, mainMenu);
                mainMenu.Update(Menu);
            }
            if (gameState != null && _GlobalState == GlobalGameState.Game)
            {
                Menu.Update(gameState.UI, gameState, mainMenu);
                gameState.Update(Menu);
            }
            else
            {
                Menu.Update(null, gameState, mainMenu);
            }

            //Window.Title = gameState.watch.Elapsed.ToString() + "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y) + "|ZOOM|" + gameState.cam.Zoom.ToString() + "|POS|" + gameState.cam.Position.ToString();
            Window.Title = "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y);

            LoadingBr.UpdateAnims();
            if (IsLoadToGame)
            {
                LoadingIterations++;
                if (LoadingIterations == 60)
                {
                    _GlobalState = GlobalGameState.Game;
                    LoadingBr.ScreenBrUp();
                }
                if (LoadingIterations == 120)
                {
                    IsLoadToGame = false;
                }
            }
            if (IsLoadToMenu)
            {
                LoadingIterations++;
                if (LoadingIterations == 60)
                {
                    _GlobalState = GlobalGameState.MainMenu;
                    mainMenu.ReturnFromGame();
                    gameState = null;
                    LoadingBr.ScreenBrUp();
                }
                if (LoadingIterations == 120)
                {
                    IsLoadToMenu = false;
                }
            }
            base.Update(gameTime);
        }