Пример #1
0
  @Override
  public void Update() {
    if (explodeTime < 0) {
      exploded = true;
      for (Bomb b : Game.getInstance().playground().getBombs()) {
        if (b == this) {
          Game.getInstance().playground().removeBombs1(b);
        }
      }
      for (Bomb b : Game.getInstance().playground().getBombs2()) {
        if (b == this) {
          Game.getInstance().playground().removeBombs2(b);
        }
      }
      try {
        createFlames();
      } catch (SlickException ex) {
        ex.printStackTrace();
      }
    }
    explodeTime--;

    ArrayList<Player> players = Game.getInstance().getAllPlayers();
    for (Player p : players) {
      if (intersects(p)) {
        if (!moving) {
          // p.setKick(true);
          if (p.getKick() && isKicked == false) {
            kickBomb(p.getKickDirection());
          }
        }
      }
    }
  }
Пример #2
0
 /**
  * This method generates panels for the team based on the amount of players It can't contain the
  * same panels. Author Qun, Kaj
  *
  * @param gamePanels this is a list of panels gotten from the Game
  * @return panels this is a list of panels that is given to a team
  */
 public List<Panel> generatePanels(List<Panel> gamePanels) {
   panels.clear();
   List<Panel> gamePanelsCopy = new ArrayList<Panel>();
   gamePanelsCopy.addAll(gamePanels);
   List<Panel> panelsGivenToPlayer;
   for (Player player : players) {
     panelsGivenToPlayer = player.generatePanels(gamePanelsCopy);
     this.panels.addAll(player.getPanels());
     generateInstructionForPlayer(player);
     gamePanelsCopy.removeAll(panelsGivenToPlayer);
   }
   return gamePanels;
 }
Пример #3
0
 /**
  * Removes player if it is in the team Author Qun, Kaj
  *
  * @param player
  */
 public Player removePlayer(Player player) {
   for (Player teamPlayers : players) {
     if (teamPlayers.getIp().equals(player.getIp())) {
       players.remove(player);
       log.log(Level.INFO, "Player " + teamPlayers.getUsername() + " is removed from the team");
     } else {
       player = null;
       log.log(Level.INFO, "Player is not removed from the team");
     }
     return player;
   }
   return null;
 }
Пример #4
0
  /**
   * Give the player a new instruction and remove his old instruction from the active instruction
   *
   * @param player The player that will get a new instruction
   * @return true if the player has the new instruction
   */
  public synchronized Instruction generateInstructionForPlayer(Player player) {
    Instruction oldInstruction = player.getActiveInstruction();

    // Generate a new instruction for the player and add this instruction to the active instruction
    Instruction instruction = player.generateInstruction();
    player.setActiveInstruction(instruction);
    activeInstructions.add(instruction);

    if (oldInstruction != null) {
      // Remove the current instruction from the active instructions
      activeInstructions.remove(oldInstruction);
      log.log(Level.INFO, "Removed the old instruction from the active instructions");
    }

    return instruction; // == player.getActiveInstruction();
  }
Пример #5
0
 /**
  * Checks if the list is empty or if the player is already in the team if there is a team and the
  * person is not in it, the player is added to the team Author Qun, Kaj
  *
  * @param player
  */
 public Player addPlayer(Player player) {
   if (this.players == null) this.players = new ArrayList<>();
   if (players.size() == 0 || !players.contains(player)) {
     players.add(player);
     player.setTeam(this);
     log.log(Level.INFO, "Player has been added to the team");
     return player;
   }
   log.log(Level.INFO, "Player has not been added to the team");
   player = null;
   return player;
 }
Пример #6
0
  public void setPlayer(Player p) {
    playerModel = p;
    nameLabel.setText(playerModel.getName());
    levelLabel.setText(Integer.toString(playerModel.getLevel()));
    combatLevelLabel.setText(Integer.toString(playerModel.getCombatLevel()));
    // Actualizamos, la información de sectario.
    if (playerModel.getClass() == CultistPlayer.class)
      cultistView.setCultist(((CultistPlayer) playerModel).getCultistCard());
    else cultistView.setCultist(new Game.Cultist("", 0));

    fillTreasurePanel(visibleTreasuresPanel, playerModel.getVisibleTreasures());
    fillTreasurePanel(hiddenTreasuresPanel, playerModel.getHiddenTreasures());
    repaint();
    revalidate();
  }
Пример #7
0
  private void discardTreasuresButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_discardTreasuresButtonActionPerformed

    // Eliminación de tesoros.
    ArrayList<Treasure> selHidden = getSelectedTreasures(hiddenTreasuresPanel);
    ArrayList<Treasure> selVisible = getSelectedTreasures(visibleTreasuresPanel);

    for (Treasure treasure : selHidden) {
      napakalakiModel.discardHiddenTreasure(treasure);
    }

    for (Treasure treasure : selVisible) {
      napakalakiModel.discardVisibleTreasure(treasure);
    }

    setPlayer(napakalakiModel.getCurrentPlayer());

    // Si el mal rollo es vacío, activamos el botón de equipar tesoros.
    if (playerModel.validState()) {
      this.enableMakeVisible();
    }

    repaint();
  } // GEN-LAST:event_discardTreasuresButtonActionPerformed