Package game.player

Examples of game.player.Player


   * Returns the only instance of RealPlayer in {@link #players}
   * @return the unique RealPlayer
   * @throws RealPlayerException
   */
  public Player getRealPlayer() throws RealPlayerException {
    Player playerFound = null;
    for (Player p:players) {
      if (p instanceof RealPlayer) {
        if(playerFound != null) {
          throw new RealPlayerException("there are several RealPlayers !");
        }
View Full Code Here


   * @param index
   * @return IAPlayer
   * @throws IAPlayerException
   */
  public Player getIAPlayer(int index) throws IAPlayerException {
    Player IA = players.get(index);
    if(IA instanceof RealPlayer) {
      if((index+1) < players.size())
        IA = players.get(index+1);
      else
        IA = players.get(index-1);
View Full Code Here

      float money = Float.parseFloat(playerElement.getAttributeValue("money"));
      String color = playerElement.getAttributeValue("color");
      Color c = new Color(Integer.parseInt(color));
     
      // RealPlayer or IAPlayer ?
      Player player = (type.equals("RealPlayer")) ?
          new RealPlayer(name, new Bank(money), c) : new IAPlayer(name, new Bank(money), c);
     
      // finally we add the Player
      game.getPlayerManager().addPlayer(player);
    }
View Full Code Here

      String playerName = baseElement.getAttributeValue("player");
      int might = Integer.parseInt(baseElement.getAttributeValue("might"));
      int nbAgents = Integer.parseInt(baseElement.getAttributeValue("nbAgents"));
     
      Vector2f position = new Vector2f(x, y);
      Player player = game.getPlayerManager().getPlayer(playerName);
     
     
      //Base base = new Base(id, might, player, position, nbAgents);
      Base base = new Base(might, player, position, nbAgents);
      base.setId(index)
View Full Code Here

   * @throws RealPlayerException 
   * @throws ClickedByRealPlayerException
   */
  public void clicked() throws RealPlayerException {
   
    Player realPlayer = null;
    try {
      realPlayer = Game.getInstance().getPlayerManager().getRealPlayer();
    } catch (RealPlayerException e) {
      e.printStackTrace();
      return;
    }
    Base selectedBases = realPlayer.getSelectedBases();
   
    // 1st case : the player doesn't have any selected base, so current one become his selected base (if it's his base) !
    if(selectedBases == null) {
     
      // if he selects a neutral base : nothing is done
      if(this.getPlayer() == null){
        System.out.println("1st case : it's a neutral base, you can't select it !");
      }
      // if he selects the base of an other player : nothing is done
      else if((this.getPlayer().getName() != realPlayer.getName())){
        System.out.println("1st case : it's not your base, you can't select it !");
      }
      // if he selects one of his base : we add the command selection
      else if((this.getPlayer().getName() == realPlayer.getName())) {

        SelectBase selectionCommand = new SelectBase(realPlayer, this);
        Engine.getInstance().getCommands().add(selectionCommand);
       
        //it sets the first point of Line, which is the coordinate of the first Base, i.e the SelectedBase
        AppliWindow.getInstance().getLine().displayFirstPoint(this);
      }
    }
   
    // 2nd case : current base is already selected by the realPlayer : nothing is done
    else if (selectedBases.equals(this)) {
      System.out.println("2nd case : Base from : "+realPlayer.getSelectedBases().getName()+" already selected.");
    }
   
    // 3rd case : the realPlayer has an other base selected : agents can go from the selected base to current one ! (and we deselect the base)
    else {
     
View Full Code Here

    game.clearGame();
   
    // How many enemies ?
    this.adversaireNumber = adv;
   
    Player michel = new RealPlayer("Michel", Color.RED);
    Player jean_luc = new IAPlayer("Jean-Luc", Color.BLUE);
    Player patrick = new IAPlayer("Patrick", Color.GREEN);
    Player germaine = new IAPlayer("Germaine", Color.ORANGE);
   
    switch(this.getAdversaireNumber()) {
   
    case 0 :
      game.getPlayerManager().addPlayer(jean_luc);
View Full Code Here

TOP

Related Classes of game.player.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.