Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            lastMilliseconds = Environment.TickCount;

            needToDraw = false;
#if DEBUG
            countFPSUpdate(gameTime);
#endif
            input.update();

            if (state == nextState)
            {
                switch (state)
                {
                case states.mission:
                    mission.doLogic();
                    break;

                case states.mainMenu:
                    mainMenu.doLogic();
                    break;

                case states.hangar:
                    hangar.doLogic();
                    break;
                }
            }
            else if (loadScreenLoaded)
            {
                needToDraw = true;
                unloadContent(state);
                switch (nextState)
                {
                case states.mainMenu:
                    if (mainMenu == null)
                    {
                        mainMenu = new MainMenu();
                    }
                    if (mainMenu.load())
                    {
                        changeState();
                    }
                    break;

                case states.hangar:
                    if (hangar == null)
                    {
                        hangar = new Hangar();
                    }
                    if (hangar.load())
                    {
                        changeState();
                    }
                    break;

                case states.mission:
                    if (mission == null)
                    {
                        mission = new Mission();
                    }
                    if (mission.load())
                    {
                        changeState();
                    }
                    break;
                }
            }
            else
            {
                unloadContent(state);
                if (loadScreen == null)
                {
                    loadScreen = new LoadScreen();
                }
                loadScreenLoaded = loadScreen.load(Content);
            }

            if (nextState == states.quit)
            {
                this.Exit();
            }

            base.Update(gameTime);

            frameCount++;
#if DEBUG
            updateCount++;
#endif

            if (state == nextState)
            {
                if (!needToDraw)
                {
#if !DEBUG
                    Sleep();
                    this.SuppressDraw();
#else
                    drawCount--;
#endif
                }
            }
        }