public void EnemyShoot() { // Shoot only if bulletdelay resets if (bulletDelay >= 0) bulletDelay--; // Creates new bullet in front & center of enemy ship if (bulletDelay <= 0) { Bullet newBullet = new Bullet(bulletTexture); newBullet.position = new Vector2(position.X + texture.Width /2 - newBullet.texture.Width/2, position.Y + 30); newBullet.isVisible = true; if (bulletList.Count() < 20) bulletList.Add(newBullet); // Reset Bullet Delay if (bulletDelay == 0) bulletDelay = 90; } }
// Shooting Mechanism (startPos,Delay,Collision) public void Shoot() { // Shoots only if bullet delay resets if (bulletDelay >= 0) bulletDelay --; // If bulletDelay is at 0 creates new bullet at player position, make it visible on the screen, then add that bullet to the list if (bulletDelay <= 0) { sm.playerShootSound.Play(); Bullet newBullet = new Bullet(bulletTexture); newBullet.position = new Vector2(position.X + 32 - newBullet.texture.Width / 2, position.Y + 30); newBullet.isVisible = true; if (bulletList.Count() < 20) // Limits fired bullets at 20 ammunition bulletList.Add(newBullet); } if (bulletDelay == 0) bulletDelay = 10; }