Updated weapon logic. Fixed player CheckMove logic.

This commit is contained in:
2026-08-24 19:46:04 -04:00
parent c1124a784d
commit e42b11c6fc
10 changed files with 279 additions and 73 deletions

View File

@@ -1,4 +1,5 @@
using AlienAttack.MonoGame.Things.Muzzles;
using AlienAttack.MonoGame.Things.Enemies.Ships;
using AlienAttack.MonoGame.Things.Muzzles;
namespace AlienAttack.MonoGame.Things.Weapons;
@@ -8,13 +9,13 @@ public class ConfigurableWeapon(WeaponDef def, WeaponState state) : Weapon
public override void Fire(Sprite owner, SpriteUpdateContext context)
{
if (owner is not Player player) return;
if (owner is not Ship ship) return;
foreach (var shot in def.Pattern.Shots)
{
// muzzle local -> world
var muzzleLocal = player.GetMuzzleLocal(shot.Muzzle); // make a fast lookup
var muzzleWorld = MuzzleMath.GetMuzzleWorld(player, muzzleLocal);
var muzzleLocal = ship.GetMuzzleLocal(shot.Muzzle); // make a fast lookup
var muzzleWorld = MuzzleMath.GetMuzzleWorld(ship, muzzleLocal);
// speed upgrade
float vx = shot.Velocity.X * state.SpeedMultiplier;
@@ -32,6 +33,14 @@ public class ConfigurableWeapon(WeaponDef def, WeaponState state) : Weapon
}
//context.AudioManager.PlayPlayerFire(); // or use _def.FireSfxKey -> audio routing
context.AudioManager.PlayPlayerFire(def.Bullet.Kind);
if (owner is Player)
{
context.AudioManager.PlayPlayerFire(def.Bullet.Kind);
}
else
{
context.AudioManager.PlayEnemyFire(def.Bullet.Kind);
}
}
}