/// <summary>
        /// The update for the cooldown bar, goes down if shooting, rises if not shooting
        /// </summary>
        /// <param name="gameTime">used to track time</param>
        /// <param name="player">passes which player the bar refers to, in case more players are made later in development(e.g. multiplayer)</param>
        public void Update(GameTime gameTime, Player player)
        {
            KeyboardState state = Keyboard.GetState();

            if (state.IsKeyDown(Keys.Space) )
            {
                if (length > -1) length -= (float)gameTime.ElapsedGameTime.TotalSeconds * 15;   //down as far as 0
                if (length > 1) player.Shoot();                        //if space player shoots only if over 1 left
            }
            else
            {
                if(length < 200 ) length += (float)gameTime.ElapsedGameTime.TotalSeconds*20;
            }
        }
Пример #2
0
        float waveSpeed; //speed at which enemies move at, changes each wave

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Sets up a new level to play, Constructor
        /// </summary>
        /// <param name="isInsane">if true the difficulty will be "insane", if false the normal difficulty will be used</param>
        public Level(bool isDifficultLevel)
        {
            time = 120;     //2 minutes

            switch (isDifficultLevel)
            {
                case false:
                    scoreMultiply = 1;
                    bulletSpeed = 200;
                    background = new AnimatedBackground(30);    //background moving at 10
                    player = new Player(10, 100, bulletSpeed);  //new player with 10 lives, speed of 100, bullet speed of 120
                    gunCooldown = new GunCooldown();            //for player shooting and gun heating up
                    enemyList = new List<GameEntity>();         //list of enemies coming
                    playerBullet = new List<Bullet>();          //list of bullets player shot
                    enemyBullet = new List<Bullet>();           //list of bullets enemy shot
                    baseShip = shipCount = baseNumber = numberOfEnemies = 20;  //initial enemy count for first wave
                    cometCount = baseComet = 0;                 //initially no comets in waves
                    spawnSpeed = 1.6f;                          //initial speed of spawn rate
                    waveSpeed = 80;                             //initial speed of enemy movement
                    wave = 1;                                   //wave counter starts at wave 1
                    break;
                case true:
                    scoreMultiply = 3;
                    bulletSpeed = 240;

                    background = new AnimatedBackground(50);    //background moving at 10
                    player = new Player(20, 150, bulletSpeed); //new player with 20 lives, speed of 150, bullet speed 180
                    gunCooldown = new GunCooldown();            //for player shooting and gun heating up
                    enemyList = new List<GameEntity>();         //list of enemies coming
                    playerBullet = new List<Bullet>();          //list of bullets player shot
                    enemyBullet = new List<Bullet>();           //list of bullets enemy shot
                    baseShip = shipCount = baseNumber = numberOfEnemies = 40;  //initial enemy count for first wave
                    cometCount = baseComet = 10;                 //initially comets in waves
                    spawnSpeed = 1.0f;                          //initial speed of spawn rate
                    waveSpeed = 170;                             //initial speed of enemy movement
                    wave = 1;                                   //wave counter starts at wave 1
                    break;
            }
        }