public override void Pickup(PlayerHandler ph) { AmmunitionInventory ai = ph.ammo; if (ai != null) { bool hasBeenConsumed = false; for (int i = 0; i < System.Enum.GetValues(typeof(AmmunitionType)).Length; i++) { AmmunitionType a = (AmmunitionType)i; if (ai.GetStock(a) < ai.GetMax(a)) { int amountToRestore = Mathf.RoundToInt(ai.GetMax(a) * (percentageValue / 100)); amountToRestore = Mathf.Clamp(amountToRestore, 1, ai.GetMax(a)); ai.Collect(a, amountToRestore); hasBeenConsumed = true; } } if (hasBeenConsumed == true) { Destroy(gameObject); } } }
public override void Pickup(Collider c) { AmmunitionInventory ai = c.GetComponent <AmmunitionInventory>(); if (ai != null && ai.GetStock(ammoType) <= ai.GetMax(ammoType)) { amount -= ai.Collect(ammoType, amount); if (amount <= 0) { Destroy(gameObject); } base.Pickup(c); } }
public override void Pickup(Collider c) { AmmunitionInventory ai = c.GetComponent <AmmunitionInventory>(); if (ai != null) { for (int i = 0; i < System.Enum.GetValues(typeof(AmmunitionType)).Length; i++) { AmmunitionType a = (AmmunitionType)i; if (a != AmmunitionType.None) { int amountToRestore = Mathf.RoundToInt(ai.GetMax(a) * (percentageValue / 100)); ai.Collect(a, amountToRestore); } } } base.Pickup(c); }
public override void Pickup(PlayerHandler ph) { AmmunitionInventory ai = ph.GetComponent <AmmunitionInventory>(); if (ai != null) { if (ai.GetStock(ammoType) < ai.GetMax(ammoType)) { amount -= ai.Collect(ammoType, amount); if (amount <= 0) { Destroy(gameObject); } else { base.Pickup(ph); } } } }