Exemplo n.º 1
0
        /// <summary>
        /// Allows the Manager component to perform initialization it needs to before starting
        /// to run. 
        /// </summary>
        public override void Initialize()
        {
            // Check for needed files
            FileHandler.CheckFiles();

            // Create the splash screen scene
            splash = new SplashScreen(game, spriteBatch, 3000);

            // Create the background entity
            background = new Background(game, spriteBatch);

            // Create the menu scene
            menu = new Menu(game, spriteBatch);

            base.Initialize();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the Manager to update itself. Updates are dependant on the 
        /// current state of the Manager
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // Update the background when not in splash screen
            if (state != ManagerState.Splash)
                background.Update(gameTime);

            // Update based on state
            if (state == ManagerState.Splash)
            {
                splash.Update(gameTime);

                // Go to main menu
                if (splash.Complete)
                {
                    menu = new Menu(game, spriteBatch);
                    splash = null;
                    state = ManagerState.Menu;
                    return;
                }
            }
            else if (state == ManagerState.Menu)
            {
                menu.Update(gameTime);

                // Go to level selected
                if (menu.LoadLevel)
                {
                    level = new Level(game, spriteBatch, menu.LevelNumber);
                    menu = null;
                    state = ManagerState.Level;
                    return;
                }
            }

            else if (state == ManagerState.Level)
            {
                level.Update(gameTime);

                // Go to main menu
                if (level.Quit)
                {
                    menu = new Menu(game, spriteBatch);
                    level = null;
                    state = ManagerState.Menu;
                    return;
                }

                // Go to next level
                else if (level.Complete)
                    LevelComplete();
            }
            else if (state == ManagerState.EndGame)
            {
                endGame.Update(gameTime);

                // Go to main menu
                if (endGame.Complete)
                {
                    menu = new Menu(game, spriteBatch);
                    splash = null;
                    state = ManagerState.Menu;
                    return;
                }
            }

            base.Update(gameTime);
        }