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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,40 @@ public static class ShotPatterns
|
||||
new Shot2(MuzzleId.Right, new Vector2(1, -6), new Vector2(4, 0))
|
||||
]
|
||||
};
|
||||
|
||||
public static readonly ShotPattern ReverseSingle = new()
|
||||
{
|
||||
Shots =
|
||||
[
|
||||
new Shot2(MuzzleId.Center, new Vector2(0, 6), new Vector2(4, 0))
|
||||
]
|
||||
};
|
||||
|
||||
public static readonly ShotPattern ReverseDouble = new()
|
||||
{
|
||||
Shots =
|
||||
[
|
||||
new Shot2(MuzzleId.Left, new Vector2(0, 6), new Vector2(4, 0)),
|
||||
new Shot2(MuzzleId.Right, new Vector2(0, 6), new Vector2(4, 0))
|
||||
]
|
||||
};
|
||||
|
||||
public static readonly ShotPattern ReverseDoubleSpread = new()
|
||||
{
|
||||
Shots =
|
||||
[
|
||||
new Shot2(MuzzleId.Left, new Vector2(-1, 6), new Vector2(4, 0)),
|
||||
new Shot2(MuzzleId.Right, new Vector2(1, 6), new Vector2(4, 0))
|
||||
]
|
||||
};
|
||||
|
||||
public static readonly ShotPattern ReverseTripleSpread = new()
|
||||
{
|
||||
Shots =
|
||||
[
|
||||
new Shot2(MuzzleId.Left, new Vector2(-1, 6), new Vector2(4, 0)),
|
||||
new Shot2(MuzzleId.Center, new Vector2(0, 6), new Vector2(4, 0)),
|
||||
new Shot2(MuzzleId.Right, new Vector2(1, 6), new Vector2(4, 0))
|
||||
]
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user