Visualization for ammo

This commit is contained in:
Marco 2025-03-05 18:55:30 +01:00
commit 07ab64a0bf
12 changed files with 252 additions and 102 deletions

View file

@ -19,7 +19,16 @@ public partial class Weapon : Node2D
public int Ammo { get; set; } = 0;
public int LoadedAmmo { get; private set; }
private int _loadedAmmo;
public int LoadedAmmo
{
get => _loadedAmmo;
private set
{
_loadedAmmo = value;
_inventoryManager?.NotifyLoadedAmmoChange(WeaponData?.ItemKey, _loadedAmmo);
}
}
public Vector2 ShootDirection { get; set; } = Vector2.Zero;
@ -61,7 +70,7 @@ public partial class Weapon : Node2D
{
// if (_inventoryManager.GetItemCount(WeaponData.AmmoKey) <= 0) return;
var ammoToLoad = _inventoryManager.RemoveItem(WeaponData.AmmoKey, WeaponData.BulletCapacity);
if (ammoToLoad > 0)
{
LoadedAmmo = ammoToLoad;
@ -127,7 +136,13 @@ public partial class Weapon : Node2D
}
LoadedAmmo -= 1;
//_inventoryManager.NotifyLoadedAmmoChange(WeaponData.ItemKey, LoadedAmmo);
// if (!string.IsNullOrWhiteSpace(WeaponData?.AmmoKey))
// {
// // Notify hud to decrease weapon
//
// }
_cooldownTimer.Start(WeaponData.RateOfFire);
_cooldownTimer.Start(WeaponData?.RateOfFire ?? 0);
}
}