// Adding or Finding weapons in the container void FindOrAddWepon(string _weaponName, int _qty) { GameObject weapon = null; foreach (GameObject w in m_Weapons) { if (w.name == _weaponName) { weapon = w; } } if (!weapon) { DEBUG.LogWarning("Weapon drop (" + _weaponName + ") is not listed in PlayerTankManager weapons container, add it"); return; } // Max QTY for weapons and save int currentQty = GetWeaponQuantity(_weaponName); int qtyCap = weapon.GetComponent <WeaponIcon>().ammoCap; for (int i = 0; i < m_loadout.Count; i++) { if (_weaponName == m_loadout[i].name) { SetWeaponQuantity(_weaponName, Math.Min(currentQty + _qty, qtyCap)); return; } } // Limit Max Slots for weapons if (m_loadout.Count < 3) { m_loadout.Add(weapon); SetWeaponQuantity(_weaponName, Math.Min(currentQty + _qty, qtyCap)); } // Loadouts if full if (m_loadout.Count >= 3) { loadoutsFull = true; } if (m_loadout.Count >= 1) { slotContents1 = m_loadout[0].name; } if (m_loadout.Count >= 2) { slotContents2 = m_loadout[1].name; } if (m_loadout.Count >= 3) { slotContents3 = m_loadout[2].name; } if (m_loadout.Count >= 4) { slotContents4 = m_loadout[3].name; } if (m_loadout.Count >= 5) { slotContents5 = m_loadout[4].name; } }