80 lines
1.9 KiB
C#
80 lines
1.9 KiB
C#
using OpenTK.Mathematics;
|
|
|
|
namespace DoomDeathmatch.Script.Model.Weapon;
|
|
|
|
public class WeaponData
|
|
{
|
|
public static WeaponData Pistol =>
|
|
new(30)
|
|
{
|
|
Id = "pistol",
|
|
Name = "Пистолет",
|
|
IdleTexture = "texture/pistol/idle.png",
|
|
FireAnimationDuration = 0.25f,
|
|
FireAnimation =
|
|
{
|
|
"texture/pistol/fire1.png", "texture/pistol/fire2.png", "texture/pistol/fire3.png", "texture/pistol/fire4.png",
|
|
},
|
|
Damage = 30,
|
|
ShootPattern = new LineShootPattern()
|
|
};
|
|
|
|
public static WeaponData Shotgun =>
|
|
new(10)
|
|
{
|
|
Id = "shotgun",
|
|
Name = "Дробовик",
|
|
IdleTexture = "texture/shotgun/idle.png",
|
|
FireAnimationDuration = 0.1f,
|
|
FireAnimation = { "texture/shotgun/fire1.png", "texture/shotgun/fire2.png" },
|
|
Damage = 5,
|
|
ShootPattern = new RandomFlatSpreadShootPattern(MathHelper.DegreesToRadians(10), 40)
|
|
};
|
|
|
|
public string Id { get; private init; } = "";
|
|
public string Name { get; private init; } = "";
|
|
public string IdleTexture { get; private init; } = "";
|
|
public float FireAnimationDuration { get; private init; } = 0;
|
|
public List<string> FireAnimation { get; private init; } = [];
|
|
public int Damage { get; private init; }
|
|
public int MaxAmmo { get; }
|
|
public IShootPattern ShootPattern { get; private init; }
|
|
|
|
public int Ammo
|
|
{
|
|
get => _ammo;
|
|
set
|
|
{
|
|
if (value < 0)
|
|
value = 0;
|
|
if (value > MaxAmmo)
|
|
value = MaxAmmo;
|
|
|
|
if (_ammo == value)
|
|
return;
|
|
|
|
_ammo = value;
|
|
OnAmmoChanged?.Invoke(this);
|
|
}
|
|
}
|
|
|
|
public event Action<WeaponData>? OnAmmoChanged;
|
|
|
|
private int _ammo;
|
|
|
|
private WeaponData(int parMaxAmmo)
|
|
{
|
|
MaxAmmo = parMaxAmmo;
|
|
Ammo = MaxAmmo;
|
|
}
|
|
|
|
public override bool Equals(object? parObj)
|
|
{
|
|
return parObj is WeaponData weaponModel && Id == weaponModel.Id;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Id);
|
|
}
|
|
} |