From d9d8a08d4666356add9c90829bbcbca8a71f8ca1 Mon Sep 17 00:00:00 2001 From: Brian Bicknell Date: Fri, 2 Jan 2026 01:21:02 -0500 Subject: [PATCH] Added more minigum options. --- AlientAttack.MonoGame/Things/Player.cs | 4 +- .../Things/Weapons/Minigun.cs | 167 ++++++++++++++++-- 2 files changed, 159 insertions(+), 12 deletions(-) diff --git a/AlientAttack.MonoGame/Things/Player.cs b/AlientAttack.MonoGame/Things/Player.cs index b4a6664..7aa03b3 100644 --- a/AlientAttack.MonoGame/Things/Player.cs +++ b/AlientAttack.MonoGame/Things/Player.cs @@ -61,8 +61,8 @@ internal class Player : MoveableSprite { BoundBox = new Rectangle(0, 0, 64, 64); //ActiveWeapons.Add(new Minigun()); - //ActiveWeapons.Add(new FastMinigun()); - ActiveWeapons.Add(new MinigunSpread()); + ActiveWeapons.Add(new MinigunTripleSpreadFast()); + //ActiveWeapons.Add(new MinigunSpread()); Health = 100; Shield = 100; } diff --git a/AlientAttack.MonoGame/Things/Weapons/Minigun.cs b/AlientAttack.MonoGame/Things/Weapons/Minigun.cs index 4bf2836..6305052 100644 --- a/AlientAttack.MonoGame/Things/Weapons/Minigun.cs +++ b/AlientAttack.MonoGame/Things/Weapons/Minigun.cs @@ -73,20 +73,167 @@ internal class MinigunSpread : Weapon } } -internal class FastMinigun : Weapon +internal abstract class MinigunSingle : 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; + FireBulletFromMuzzleContext fireBulletContext = new() + { + Owner = owner, + SpriteUpdateContext = context, + BulletWidth = MinigunBulletSmall.Width, + BulletHeight = MinigunBulletSmall.Height, + Factory = (x, y, vx, vy2, o) => new MinigunBulletSmall(x, y, vx, vy2, o), + ExtraOffset = new(4f, 0), + Shots = + [ + new() { Muzzle = MuzzleId.Center, XVelocity = 0, YVelocity = -6 } + ] + }; - // Create bullets with velocity (0, -4) - MinigunBulletSmall bullet = new(x, y, 0, -6, owner); + FireFromMuzzle(fireBulletContext); - // Queue the bullets for spawning - context.SpawnSprite(bullet); + context.AudioManager.PlayPlayerFire(); } +} + +internal class MinigunSingleSlow : MinigunSingle +{ + public override int FireThreshold => 20; +} + +internal class MinigunSingleAverage : MinigunSingle +{ + public override int FireThreshold => 15; +} + + +internal class MinigunSingleFast : MinigunSingle +{ + public override int FireThreshold => 10; +} + +internal abstract class MinigunDouble : Weapon +{ + public override void Fire(Sprite owner, SpriteUpdateContext context) + { + FireBulletFromMuzzleContext fireBulletContext = new() + { + Owner = owner, + SpriteUpdateContext = context, + BulletWidth = MinigunBulletMedium.Width, + BulletHeight = MinigunBulletMedium.Height, + Factory = (x, y, vx, vy2, o) => new MinigunBulletMedium(x, y, vx, vy2, o), + ExtraOffset = new(4f, 0), + Shots = + [ + new() { Muzzle = MuzzleId.Left, XVelocity = 0, YVelocity = -6 }, + new() { Muzzle = MuzzleId.Right, XVelocity = 0, YVelocity = -6 } + ] + }; + + FireFromMuzzle(fireBulletContext); + + context.AudioManager.PlayPlayerFire(); + } +} + +internal class MinigunDoubleSlow : MinigunDouble +{ + public override int FireThreshold => 30; +} + +internal class MinigunDoubleAverage : MinigunDouble +{ + public override int FireThreshold => 20; +} + + +internal class MinigunDoubleFast : MinigunDouble +{ + public override int FireThreshold => 15; +} + +internal abstract class MinigunTriple : Weapon +{ + public override void Fire(Sprite owner, SpriteUpdateContext context) + { + FireBulletFromMuzzleContext fireBulletContext = new() + { + Owner = owner, + SpriteUpdateContext = context, + BulletWidth = MinigunBulletMedium.Width, + BulletHeight = MinigunBulletMedium.Height, + Factory = (x, y, vx, vy2, o) => new MinigunBulletMedium(x, y, vx, vy2, o), + ExtraOffset = new(4f, 0), + Shots = + [ + new() { Muzzle = MuzzleId.Left, XVelocity = 0, YVelocity = -6 }, + new() { Muzzle = MuzzleId.Center, XVelocity = 0, YVelocity = -6 }, + new() { Muzzle = MuzzleId.Right, XVelocity = 0, YVelocity = -6 } + ] + }; + + FireFromMuzzle(fireBulletContext); + + context.AudioManager.PlayPlayerFire(); + } +} + +internal class MinigunTripleSlow : MinigunTriple +{ + public override int FireThreshold => 30; +} + +internal class MinigunTripleAverage : MinigunTriple +{ + public override int FireThreshold => 20; +} + + +internal class MinigunTripleFast : MinigunTriple +{ + public override int FireThreshold => 15; +} + +internal abstract class MinigunTripleSpread : Weapon +{ + public override void Fire(Sprite owner, SpriteUpdateContext context) + { + FireBulletFromMuzzleContext fireBulletContext = new() + { + Owner = owner, + SpriteUpdateContext = context, + BulletWidth = MinigunBulletLarge.Width, + BulletHeight = MinigunBulletLarge.Height, + Factory = (x, y, vx, vy2, o) => new MinigunBulletLarge(x, y, vx, vy2, o), + ExtraOffset = new(4f, 0), + Shots = + [ + new() { Muzzle = MuzzleId.Left, XVelocity = -1, YVelocity = -6 }, + new() { Muzzle = MuzzleId.Right, XVelocity = 1, YVelocity = -6 }, + new() { Muzzle = MuzzleId.Center, XVelocity = 0, YVelocity = -6 } + ] + }; + + FireFromMuzzle(fireBulletContext); + + context.AudioManager.PlayPlayerFire(); + } +} + +internal class MinigunTripleSpreadSlow : MinigunTripleSpread +{ + public override int FireThreshold => 30; +} + +internal class MinigunTripleSpreadAverage : MinigunTripleSpread +{ + public override int FireThreshold => 20; +} + + +internal class MinigunTripleSpreadFast : MinigunTripleSpread +{ + public override int FireThreshold => 15; } \ No newline at end of file