public void applyChoice() { int[] choices = new int[BombType.B_NUM]; for (int type = 0; type < BombType.B_NUM; type++) { choices[type] = b_choices[type].getSelectedIndex(); } bomber.setBombChoices(choices); } public int[] getChoice() {
@Override public void setBombChoices(int[] bc) { // Set the bombs for the squadron if (bc.length == bombChoices.length) { bombChoices = bc; } // Update each fighter in the squadron for (Integer fId : fighters) { IBomber fighter = (IBomber) game.getEntity(fId); fighter.setBombChoices(bc); } }
((IBomber) entity).setBombChoices(bombChoices);
/** * Helper function that makes some of the units in the given list of entities * carry bombs. * @param entityList The list of entities to process * @param campaign Campaign object. In the future, may be used to check list of bombs * for technological availability. */ private static void populateAeroBombs(List<Entity> entityList, Campaign campaign) { int maxBombers = Compute.randomInt(entityList.size()) + 1; int numBombers = 0; for(Entity entity : entityList) { if(numBombers >= maxBombers) { break; } if(entity.isBomber()) { int[] bombChoices = new int[BombType.B_NUM]; int numBombs = (int) (entity.getWeight() / 5); int bombIndex = validBotBombs[(Compute.randomInt(validBotBombs.length))]; bombChoices[bombIndex] = numBombs; ((megamek.common.IBomber) entity).setBombChoices(bombChoices); numBombers++; } } }
bomber.setBombChoices(bombChoices); bomber.clearBombs();