Ejemplo n.º 1
0
 private void ClearEmitter()
 {
     for (int index = EnemyPlaneList.Count - 1; index >= 0; --index)
     {
         if (!(EnemyPlaneList[index] is BaseSpellCard))
         {
             EnemyPlaneList[index].GiveEndEffect();
             EnemyPlaneList.RemoveAt(index);
         }
     }
     foreach (BaseObject bullet in BulletList)
     {
         bullet.GiveEndEffect();
     }
     BulletList.Clear();
 }
Ejemplo n.º 2
0
 public void ClearList()
 {
     for (int i = NextLevelEntityList.Count - 1; i >= 0; i--)
     {
         NextLevelEntityList[i].Destroy();
     }
     for (int x = ActionEntityList.Count - 1; x >= 0; x--)
     {
         ActionEntityList[x].Destroy();
     }
     for (int z = BulletList.Count - 1; z >= 0; z--)
     {
         BulletList[z].Destroy();
     }
     for (int y = SignEntityList.Count - 1; y >= 0; y--)
     {
         SignEntityList[y].Destroy();
     }
     for (int g = EnemyCornerList.Count - 1; g >= 0; g--)
     {
         EnemyCornerList[g].Destroy();
     }
     for (int h = GroundEnemyList.Count - 1; h >= 0; h--)
     {
         GroundEnemyList[h].Destroy();
     }
     for (int o = EnemyBulletList.Count - 1; o >= 0; o--)
     {
         EnemyBulletList[o].Destroy();
     }
     NextLevelEntityList.Clear();
     ActionEntityList.Clear();
     BulletList.Clear();
     EnemyBulletList.Clear();
     GroundEnemyList.Clear();
     SignEntityList.Clear();
     EnemyCornerList.Clear();
 }
Ejemplo n.º 3
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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            currState = Keyboard.GetState(); //Update keyboard state


            //If the game is at the menu, only check if the player pressed enter.
            if (gameState == GameState.Menu)
            {
                if (currState.IsKeyUp(Keys.Enter) && prevState.IsKeyDown(Keys.Enter))
                {
                    gameState = GameState.Controls;
                }

                prevState = currState; //Set previous state to last current state
            }
            //If the game is at the controls
            else if (gameState == GameState.Controls)
            {
                if (currState.IsKeyUp(Keys.Enter) && prevState.IsKeyDown(Keys.Enter))
                {
                    gameState = GameState.InWave;
                }
            }
            //If the game is playing
            else if (gameState == GameState.InWave)
            {
                if (P1.Health <= 0)
                {
                    gameState = GameState.GameOver;

                    //Clear out the bullets
                    BulletList.Clear();
                    PlayerBulletList.Clear();
                }

                //Check if the player paused the game
                if (currState.IsKeyUp(Keys.P) && prevState.IsKeyDown(Keys.P))
                {
                    gameState = GameState.Pause;
                }
                // activate developer tool
                if (currState.IsKeyUp(Keys.F1) && prevState.IsKeyDown(Keys.F1))
                {
                    GameBalanceTool gameBalance = new GameBalanceTool();
                    gameBalance.Show();
                }

                //Check for player movement
                P1.Movement();


                //Move and Manage enemies and bullets
                MoveBullets();
                MoveEnemies();

                BulletManage();
                EnemyManage();

                //Manage the wave
                WaveManage();


                /** Threading code to use if optimization needed
                 * bulletThread = new Thread(BulletManage);
                 * bulletThread.Start();
                 */

                //keeps tank from moving past screen
                if (P1.position.X < 0)
                {
                    P1.position.X = 0;
                }
                if (P1.position.X > GAME_WIDTH - P1.position.Width)
                {
                    P1.position.X = GAME_WIDTH - P1.position.Width;
                }
            }
            else if (gameState == GameState.Pause)
            {
                //Check if player unpaused the game
                if (currState.IsKeyUp(Keys.P) && prevState.IsKeyDown(Keys.P))
                {
                    gameState = GameState.InWave;
                }
            }
            else if (gameState == GameState.GameOver)
            {
                if (currState.IsKeyUp(Keys.Enter) && prevState.IsKeyDown(Keys.Enter))
                {
                    //Reset player
                    P1.Reset();

                    //Clear all active items off screen
                    bulletList.Clear();
                    playerBulletList.Clear();
                    enemyList.Clear();

                    //Reset the wave
                    currWave     = new Wave();
                    enemyIndex   = 0;
                    currCoolDown = spawnCoolDown;

                    gameState = GameState.InWave; //Go back to a new game
                }
            }

            prevState = currState; //Update prev keyboard state

            base.Update(gameTime);
        }