26 lines
641 B
C#
26 lines
641 B
C#
namespace AlienAttack.MonoGame.Things.Weapons;
|
|
|
|
public abstract class Weapon : IWeapon
|
|
{
|
|
public abstract int FireThreshold { get; }
|
|
public int CurrentFireThreshold { get; private set; }
|
|
|
|
public void UpdateFireThreshold()
|
|
{
|
|
if (CurrentFireThreshold > 0)
|
|
CurrentFireThreshold--;
|
|
}
|
|
|
|
public bool TryFire(Sprite owner, SpriteUpdateContext context)
|
|
{
|
|
if (CurrentFireThreshold > 0)
|
|
return false;
|
|
|
|
Fire(owner, context);
|
|
CurrentFireThreshold = FireThreshold;
|
|
|
|
return true;
|
|
}
|
|
|
|
public abstract void Fire(Sprite owner, SpriteUpdateContext context);
|
|
} |