예제 #1
0
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   backButton.setCancelButton(true);
   Config.getInstance().playerList = new Player[Config.getInstance().maxPlayers];
   adjustPlayerCount();
   assert raceCombo != null
       : "fx:id=\"myChoices\" was not injected: check your FXML file 'foo.fxml'.";
   raceCombo.setItems(FXCollections.observableArrayList());
   raceCombo.getItems().add("FOLD");
   raceCombo.getItems().add("FAULT-BLOCK");
   raceCombo.getItems().add("DOME");
   raceCombo.getItems().add("VOLCANIC");
   raceCombo.getItems().add("PLATEAU");
   updateValues();
 }
예제 #2
0
 @FXML
 private void handleColorAction(ActionEvent e) {
   invalidColor = false;
   for (Player player : Config.getInstance().playerList) {
     if (colorPicker.getValue().equals(player.getColor())) {
       invalidColor = true;
     }
   }
   if (invalidColor) {
     colorLabel.setTextFill(Color.RED); // disallow same colors
   } else {
     colorLabel.setTextFill(Color.BLACK);
   }
   Config.getInstance()
       .playerList[Config.getInstance().currentPlayer]
       .setColor(colorPicker.getValue());
 }
예제 #3
0
 @FXML
 private void handleNameAction(Event e) {
   emptyName = false;
   for (Player player : Config.getInstance().playerList) {
     if (player.getName().equals("") && player.getId() < numSlider.getValue()) {
       emptyName = true;
     }
   }
   if (emptyName) {
     nameLabel.setTextFill(Color.RED); // disallow empty name
     startButton.setDisable(true);
   } else {
     nameLabel.setTextFill(Color.BLACK);
     startButton.setDisable(false);
   }
   Config.getInstance()
       .playerList[Config.getInstance().currentPlayer]
       .setName(nameField.getText());
 }
예제 #4
0
 private void updateValues() {
   raceCombo
       .getSelectionModel()
       .select(
           Config.getInstance()
               .playerList[Config.getInstance().currentPlayer]
               .getRace()
               .ordinal());
   colorPicker.setValue(
       Config.getInstance().playerList[Config.getInstance().currentPlayer].getColor());
   nameField.setText(
       Config.getInstance().playerList[Config.getInstance().currentPlayer].getName());
   playerSlider.setValue(Config.getInstance().currentPlayer + 1);
 }
예제 #5
0
 @FXML
 private void handleEnterAction(Event e) {
   numSlider.setValue(Config.getInstance().numOfPlayers);
   adjustPlayerCount();
 }
예제 #6
0
 public void onSetScene() {
   Config.getInstance().soundManager.changePlaylist(Config.getInstance().titlePlaylist);
 }
예제 #7
0
 private void changePlayer(int id) {
   Config.getInstance().currentPlayer = id;
   updateValues();
 }
예제 #8
0
 private void adjustPlayerCount() {
   int difficulty = 0;
   if (Config.getInstance().difficulty == Difficulty.HILL) {
     difficulty = 0;
   } else if (Config.getInstance().difficulty == Difficulty.MESA) {
     difficulty = 1;
   } else if (Config.getInstance().difficulty == Difficulty.PLATEAU) {
     difficulty = 2;
   } else if (Config.getInstance().difficulty == Difficulty.MOUNTAIN) {
     difficulty = 3;
   }
   int foodCount;
   if (difficulty == 0) {
     foodCount = 8;
   } else {
     foodCount = 4;
   }
   int energyCount;
   if (difficulty == 0) {
     energyCount = 4;
   } else {
     energyCount = 2;
   }
   for (int i = 0; i < Config.getInstance().maxPlayers; i++) {
     if (Config.getInstance().playerList[i] == null) {
       Config.getInstance().playerList[i] = new Player(i);
       Config.getInstance().playerList[i].changeStockOf(ResourceType.ENERGY, energyCount);
       Config.getInstance().playerList[i].changeStockOf(ResourceType.FOOD, foodCount);
     }
   }
   playerSlider.setMax(Config.getInstance().numOfPlayers);
   if (Config.getInstance().currentPlayer >= Config.getInstance().numOfPlayers) {
     changePlayer(0);
   }
 }
예제 #9
0
 @FXML
 private void handleRaceAction(ActionEvent e) {
   Config.getInstance()
       .playerList[Config.getInstance().currentPlayer]
       .setRace(Race.values()[raceCombo.getSelectionModel().getSelectedIndex()]);
 }
예제 #10
0
 @FXML
 private void handleNumAction(Event e) {
   Config.getInstance().numOfPlayers = (int) numSlider.getValue();
   adjustPlayerCount();
 }