239 lines
7.2 KiB
C#
239 lines
7.2 KiB
C#
using AlienAttack.MonoGame.Things.Bullets;
|
|
using AlienAttack.MonoGame.Things.Muzzles;
|
|
|
|
namespace AlienAttack.MonoGame.Things.Weapons;
|
|
|
|
internal 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();
|
|
}
|
|
}
|
|
|
|
internal class MinigunSpread : Weapon
|
|
{
|
|
public override int FireThreshold => 20;
|
|
|
|
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 x3 = (int)owner.XPosition + owner.BoundBox.Width / 2 - 1;
|
|
int y = (int)owner.YPosition + 10;
|
|
|
|
MinigunBulletLarge bullet1 = new(x1, y, -1, -6, owner);
|
|
MinigunBulletLarge bullet2 = new(x2, y, 1, -6, owner);
|
|
MinigunBulletLarge bullet3 = new(x3, y-16, 0, -6, owner);
|
|
|
|
//context.SpawnSprite(bullet1);
|
|
//context.SpawnSprite(bullet2);
|
|
//context.SpawnSprite(bullet3);
|
|
|
|
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 abstract class MinigunSingle : Weapon
|
|
{
|
|
public override void Fire(Sprite owner, SpriteUpdateContext context)
|
|
{
|
|
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 }
|
|
]
|
|
};
|
|
|
|
FireFromMuzzle(fireBulletContext);
|
|
|
|
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;
|
|
} |