Add project files.
This commit is contained in:
26
AlientAttack.MonoGame/Things/Weapons/Weapon.cs
Normal file
26
AlientAttack.MonoGame/Things/Weapons/Weapon.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user