Asteroids.Classes.Alien.ShootBullet C# (CSharp) Method

ShootBullet() public method

public ShootBullet ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void
        public void ShootBullet(GameTime gameTime)
        {
            this.origin = new Vector2(position.X + drawTexture.Width / 2, position.Y + drawTexture.Height / 2);
            shottimer += gameTime.ElapsedGameTime.Milliseconds;

            if (shottimer > timeBetweenShots)
            {
                shottimer = 0;
                BulletAlien b = new BulletAlien(
                    bulletTexture,
                    this.origin,
                    this.direction,
                    1, // The speed
                    2000); // The active time in Milliseconds
                bullets.Add(b);
            }
            for (int i = 0; i < bullets.Count; i++)
            {
                bullets[i].Update(gameTime);

                if (bullets[i].totalActiveTime > bullets[i].activeTime)
                    bullets.RemoveAt(i);
            }
            direction.X = rnd.Next(-5, 5);
            direction.Y = rnd.Next(-5, 5);
        }