示例#1
0
  public void finishButtonActionPerformed() {
    if (robotSelectionPanel.getSelectedRobotsCount() > 24) {
      if (JOptionPane.showConfirmDialog(
              this,
              "Warning:  The battle you are about to start ("
                  + robotSelectionPanel.getSelectedRobotsCount()
                  + " robots) "
                  + " is very large and will consume a lot of CPU and memory.  Do you wish to proceed?",
              "Large Battle Warning",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    if (robotSelectionPanel.getSelectedRobotsCount() == 1) {
      if (JOptionPane.showConfirmDialog(
              this,
              "You have only selected one robot.  For normal battles you should select at least 2.\nDo you wish to proceed anyway?",
              "Just one robot?",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    battleProperties.setSelectedRobots(robotSelectionPanel.getSelectedRobotsAsString());
    battleProperties.setBattlefieldWidth(getBattleFieldTab().getBattleFieldWidth());
    battleProperties.setBattlefieldHeight(getBattleFieldTab().getBattleFieldHeight());
    battleProperties.setNumRounds(getRobotSelectionPanel().getNumRounds());
    battleProperties.setGunCoolingRate(getRulesTab().getGunCoolingRate());
    battleProperties.setInactivityTime(getRulesTab().getInactivityTime());

    // Dispose this dialog before starting the battle due to pause/resume battle state
    dispose();

    // Start new battle after the dialog has been disposed and hence has called resumeBattle()
    manager.getBattleManager().startNewBattle(battleProperties, false);
  }
示例#2
0
 public RobotSelectionPanel getRobotSelectionPanel() {
   if (robotSelectionPanel == null) {
     robotSelectionPanel =
         net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class);
     robotSelectionPanel.setup(
         MIN_ROBOTS,
         MAX_ROBOTS,
         false,
         "Select the robot you would like to extract to the robots directory.  Robots not shown do not include source.",
         true,
         true,
         true,
         false,
         true,
         true,
         null);
   }
   return robotSelectionPanel;
 }