void PickedUpAmmo(string ammoName, int quantity) { for (int i = 0; i < typesOfAmmunition.Count; i++) //how to iterate through the ammo types list { if (typesOfAmmunition[i].ammoName == ammoName) //if a match is found { typesOfAmmunition [i].ammoCurrentCarried += quantity; // add the quantity to the ammo type //Check ammo amount during pickup, if higher than max quantity, make max quantity if (typesOfAmmunition [i].ammoCurrentCarried > typesOfAmmunition [i].ammoMaxQuantity) { typesOfAmmunition [i].ammoCurrentCarried = typesOfAmmunition [i].ammoMaxQuantity; } //this will check the gun script and show the correct ammo, depending on the gun object playerMaster.CallEventAmmoChanged(); break; //get out of for loop, no need to iterate again } } }