public final void cycleWeapon(int direction) { do { weaponIndex += direction; if (weaponIndex < 0) { weaponIndex = weapons.size() - 1; } else if (weaponIndex >= weapons.size()) { weaponIndex = 0; } weapon = weapons.get(weaponIndex); } while (weapon.getAmmo() + weapon.getRounds() == 0); ViewFrame.getInstance().setWeapon(weapon.toString()); displayAmmo(); }
public final void setWeapon(int weaponIndex) { weapon = weapons.get(weaponIndex); ViewFrame.getInstance().setWeapon(weapon.toString()); }