/// <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 SCREEN_WIDTH = graphics.GraphicsDevice.Viewport.Width; SCREEN_HEIGHT = graphics.GraphicsDevice.Viewport.Height; gameAssets = new GameAssets(); objectFactory = new Factory(gameAssets); spriteManager = new SpriteManager(); spriteBatch = new SpriteBatch(GraphicsDevice); viewPort = new ViewPort(spriteBatch, SCREEN_WIDTH, SCREEN_HEIGHT); colliderHandler = new ColliderHandler(); gameState = new Intro(); currentGameState = -1; wave = 1; //playGame = new PlayGame(gameAssets, viewPort, objectFactory, colliderHandler); //gameState.CurrentGameState = (int)GAME_STATES.PLAY_GAME; base.Initialize(); }
/// <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 (currentGameState != gameState.CurrentGameState) { switch (gameState.CurrentGameState) { case (int)GAME_STATES.INTRO: break; case (int)GAME_STATES.MENU: break; case (int)GAME_STATES.PLAY_GAME: gameState = new PlayGame(gameAssets, viewPort, objectFactory, colliderHandler); break; case (int)GAME_STATES.OPTIONS: break; case (int)GAME_STATES.END: break; default: break; } currentGameState = gameState.CurrentGameState; } gameState.Update(gameTime); base.Update(gameTime); }