Exemplo n.º 1
0
 private static void CreateLargeExplosion(Vector2 location)
 {
     EffectsManager.AddLargeExplosion(location + new Vector2(-10, -10));
     EffectsManager.AddLargeExplosion(location + new Vector2(-10, 10));
     EffectsManager.AddLargeExplosion(location + new Vector2(10, -10));
     EffectsManager.AddLargeExplosion(location + new Vector2(10, 10));
 }
Exemplo n.º 2
0
 private static void CheckShotEnemyImpacts(Sprite shot)
 {
     if (shot.Expired)
     {
         return;
     }
     foreach (Enemy enemy in EnemyManager.Enemies)
     {
         if (!enemy.Destroyed)
         {
             if (shot.IsCircleColliding(enemy.EnemyBase.WorldCenter, enemy.EnemyBase.CollisionRadius))
             {
                 shot.Expired       = true;
                 enemy.Destroyed    = true;
                 GameManager.Score += 10;
                 if (shot.Frame == 0)
                 {
                     EffectsManager.AddExplosion(enemy.EnemyBase.WorldCenter, enemy.EnemyBase.Velocity / 30);
                 }
                 else
                 {
                     if (shot.Frame == 1)
                     {
                         CreateLargeExplosion(shot.WorldCenter);
                         CheckRocketSplashDamage(shot.WorldCenter);
                     }
                 }
             }
         }
     }
 }
        private static void checkShotWallImpacts(Sprite shot)
        {
            if (shot.Expired)
            {
                return;
            }

            if (TileMap.IsWallTile(
                    TileMap.GetSquareAtPixel(shot.WorldCenter)))
            {
                shot.Expired = true;

                if (shot.Frame == 0)
                {
                    EffectsManager.AddSparksEffect(
                        shot.WorldCenter,
                        shot.Velocity);
                }
                else
                {
                    createLargeExplosion(shot.WorldCenter);
                    checkRocketSplashDamage(shot.WorldCenter);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            spriteSheet = Content.Load <Texture2D>(@"Textures\SpriteSheet");
            titleScreen = Content.Load <Texture2D>(@"Textures\TitleScreen");
            arialFont   = Content.Load <SpriteFont>(@"Fonts\ArialFont");

            Camera.WorldRectangle = new Rectangle(0, 0, 1600, 1600);
            Camera.ViewPortWidth  = 800;
            Camera.ViewPortHeight = 600;

            TileMap.Initialize(spriteSheet);
            TileMap.GenerateRandomMap();

            Player.Initialize(spriteSheet, new Rectangle(0, 64, 32, 32), 6,
                              new Rectangle(0, 96, 32, 32), 1, new Vector2(32, 32));

            EffectsManager.Initialize(spriteSheet, new Rectangle(0, 288, 2, 2),
                                      new Rectangle(0, 256, 32, 32), 3);

            WeaponManager.Texture = spriteSheet;

            GoalManager.Initialize(spriteSheet, new Rectangle(0, 7 * 32, 32, 32), new Rectangle(3 * 32, 7 * 32, 32, 32), 3, 1);

            EnemyManager.Initialize(spriteSheet, new Rectangle(0, 160, 32, 32));
        }
Exemplo n.º 5
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
                ButtonState.Pressed)
            {
                this.Exit();
            }

            switch (gameState)
            {
            case GameStates.TitleScreen:
                if ((GamePad.GetState(PlayerIndex.One).Buttons.A ==
                     ButtonState.Pressed) ||
                    (Keyboard.GetState().IsKeyDown(Keys.Space)))
                {
                    GameManager.StartNewGame();
                    gameState = GameStates.Playing;
                }
                break;

            case GameStates.Playing:
                Player.Update(gameTime);
                WeaponManager.Update(gameTime);
                EnemyManager.Update(gameTime);
                EffectsManager.Update(gameTime);
                GoalManager.Update(gameTime);
                if (GoalManager.ActiveTerminals == 0)
                {
                    gameState = GameStates.WaveComplete;
                }
                break;

            case GameStates.WaveComplete:
                waveCompleteTimer +=
                    (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (waveCompleteTimer > waveCompleteDelay)
                {
                    GameManager.StartNewWave();
                    gameState         = GameStates.Playing;
                    waveCompleteTimer = 0.0f;
                }
                break;

            case GameStates.GameOver:
                gameOverTimer +=
                    (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (gameOverTimer > gameOverDelay)
                {
                    gameState     = GameStates.TitleScreen;
                    gameOverTimer = 0.0f;
                }
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 6
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            TileMap.Draw(spriteBatch);
            Player.Draw(spriteBatch);
            EffectsManager.Draw(spriteBatch);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 7
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            Player.Update(gameTime);
            EffectsManager.Update(gameTime);


            base.Update(gameTime);
        }
Exemplo n.º 8
0
        private static void CheckRocketSplashDamage(Vector2 location)
        {
            int rocketSplashRadius = 40;

            foreach (Enemy enemy in EnemyManager.Enemies)
            {
                if (!enemy.Destroyed)
                {
                    if (enemy.EnemyBase.IsCircleColliding(location, rocketSplashRadius))
                    {
                        enemy.Destroyed    = true;
                        GameManager.Score += 10;
                        EffectsManager.AddExplosion(enemy.EnemyBase.WorldCenter, Vector2.Zero);
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            spriteSheet = Content.Load <Texture2D>(@"Textures\SpriteSheet");
            titleScreen = Content.Load <Texture2D>(@"Textures\TitleScreen");
            pericles14  = Content.Load <SpriteFont>(@"Fonts\Pericles14");

            Player.Initialize(spriteSheet, new Rectangle(0, 64, 32, 32), 6, new Rectangle(0, 96, 32, 32), 1, new Vector2(300, 300));
            EffectsManager.Initialize(spriteSheet, new Rectangle(0, 288, 2, 2), new Rectangle(0, 256, 32, 32), 3);

            TileMap.Initialize(spriteSheet);

            Camera.WorldRectangle = new Rectangle(0, 0, 1600, 1600);
            Camera.ViewPortWidth  = 800;
            Camera.ViewPortHeight = 600;
        }
Exemplo n.º 10
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen, new Rectangle(0, 0, 800, 600), Color.White);
            }

            if ((gameState == GameStates.Playing) || (gameState == GameStates.WaveComplete) || (gameState == GameStates.GameOver))
            {
                TileMap.Draw(spriteBatch);
                WeaponManager.Draw(spriteBatch);
                Player.Draw(spriteBatch);
                EnemyManager.Draw(spriteBatch);
                EffectsManager.Draw(spriteBatch);
                GoalManager.Draw(spriteBatch);

                checkPlayerDeath();
                spriteBatch.DrawString(arialFont, "Score: " + GameManager.Score.ToString(), new Vector2(30, 5), Color.White);
                spriteBatch.DrawString(arialFont, "Terminals Remaining: " + GoalManager.ActiveTerminals, new Vector2(520, 5), Color.White);
            }

            if (gameState == GameStates.WaveComplete)
            {
                spriteBatch.DrawString(arialFont, "Beginning Wave " + (GameManager.CurrentWave + 1).ToString(), new Vector2(300, 300), Color.White);
            }

            if (gameState == GameStates.GameOver)
            {
                spriteBatch.DrawString(arialFont, "G A M E O V E R!", new Vector2(300, 300), Color.White);
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }