Updated weapon logic. Fixed player CheckMove logic.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user