示例#1
0
文件: Game.cs 项目: ctoneal/asteroids
 /// <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)
 {
     currentScreen.Update(gameTime);
     if (currentScreen.Exit)
     {
         switch (gameState)
         {
             case state.SplashScreen:
                 {
                     currentScreen = new TitleScreen(this);
                     gameState = state.TitleScreen;
                     break;
                 }
             case state.LevelSplashScreen:
                 {
                     if (level % 2 == 0)
                     {
                         currentScreen = new BossFightScreen(this);
                         gameState = state.BossFightScreen;
                     }
                     else
                     {
                         currentScreen = new GameplayScreen(this);
                         gameState = state.GameplayScreen;
                     }
                     break;
                 }
             case state.GameplayScreen:
             case state.BossFightScreen:
                 {
                     if (((GameplayScreen)currentScreen).NextLevel)
                     {
                         level++;
                         currentScreen = new LevelSplashScreen(this);
                         gameState = state.LevelSplashScreen;
                     }
                     else
                     {
                         currentScreen = new GameOverScreen(this);
                         gameState = state.GameOverScreen;
                     }
                     break;
                 }
             case state.GameOverScreen:
                 {
                     currentScreen = new LevelSplashScreen(this);
                     SetupGame();
                     break;
                 }
             //case state.IntroCutscene:
             //    {
             //        currentScreen = new LevelSplashScreen(this);
             //        break;
             //    }
             case state.TitleScreen:
             default:
                 {
                     //currentScreen = new IntroCutscene(this);
                     currentScreen = new GameplayScreen(this);
                     SetupGame();
                     break;
                 }
         }
     }
 }
示例#2
0
文件: Game.cs 项目: ctoneal/asteroids
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            screenRect.Height = graphics.GraphicsDevice.Viewport.Height;
            screenRect.Width = graphics.GraphicsDevice.Viewport.Width;
            gameState = state.SplashScreen;
            currentScreen = new SplashScreen(this);
        }