public virtual int GiveAmmo(AmmoType ammoType, int amount) { if (!ammo.ContainsKey(ammoType)) { ammo.Add(ammoType, amount); return(0); } else { if (ammo[ammoType] + amount > ammoType.GetMaxCapacity()) { int leftOverAmmo = (ammo[ammoType] + amount) - ammoType.GetMaxCapacity(); ammo[ammoType] = ammoType.GetMaxCapacity(); return(leftOverAmmo); } else { ammo[ammoType] = ammo[ammoType] + amount; return(0); } } }
public virtual void SetAmmo(AmmoType ammoType, int amount) { if (!ammo.ContainsKey(ammoType)) { ammo.Add(ammoType, amount); } else { if (amount > ammoType.GetMaxCapacity()) { ammo[ammoType] = ammoType.GetMaxCapacity(); } else { ammo[ammoType] = amount; } } }