Files
alien-attack/AlientAttack.MonoGame/Things/Weapons/Minigun.cs

50 lines
1.7 KiB
C#

using AlienAttack.MonoGame.Things.Bullets;
using Microsoft.Xna.Framework.Audio;
namespace AlienAttack.MonoGame.Things.Weapons;
public class Minigun : Weapon
{
public override int FireThreshold => 15;
public override void Fire(Sprite owner, SpriteUpdateContext context)
{
// Calculate bullet spawn positions relative to the player's bounding box
int x1 = (int)owner.XPosition + 14;
int x2 = (int)owner.XPosition + owner.BoundBox.Width - 16;
int y = (int)owner.YPosition + 10;
// Create bullets with velocity (0, -4)
MinigunBulletLarge bullet1 = new(x1, y, 0, -6, owner);
MinigunBulletLarge bullet2 = new(x2, y, 0, -6, owner);
// Queue the bullets for spawning
context.SpawnSprite(bullet1);
context.SpawnSprite(bullet2);
//int number = context.Random.Next(1, 7);
//SoundEffect soundEffect = context.Content.Load<SoundEffect>(@$"Sfx\GUNAuto_Assault Rifle A Fire_0{number}_SFRMS_SCIWPNS");
//soundEffect.Play(0.25f, (float)(context.Random.NextDouble() * 0.1 - 0.05), 0);
context.AudioManager.PlayPlayerFire();
}
}
public class FastMinigun : Weapon
{
public override int FireThreshold => 10;
public override void Fire(Sprite owner, SpriteUpdateContext context)
{
// Calculate bullet spawn positions relative to the player's bounding box
float x = (owner.Position.X - (7/2) + owner.BoundBox.Width / 2);
float y = owner.YPosition - 16;
// Create bullets with velocity (0, -4)
MinigunBulletSmall bullet = new(x, y, 0, -6, owner);
// Queue the bullets for spawning
context.SpawnSprite(bullet);
}
}