Пример #1
0
  public void startPlayingGame() {
    // set initial position for each player and create Hero
    HeroFactory hF = new HeroFactory();
    for (Iterator it = team2.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      System.out.println("slot Index:" + player.getSlotIndex());
      System.out.println("dao:" + dao);
      Cell c = dao.getHeroBeginPosition(player.getSlotIndex());
      player.setPosition(c);
      System.out.println("hero Index:" + player.getHeroIndex());
      player.setHero(hF.createHero(player.getHeroIndex()));
    }
    for (Iterator it = team1.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      Cell c = dao.getHeroBeginPosition(player.getSlotIndex());
      player.setPosition(c);
      System.out.println("hero Index:" + player.getHeroIndex());
      player.setHero(hF.createHero(player.getHeroIndex()));
    }
    PlayingGameRequest request = new PlayingGameRequest();
    request.setGame(this);

    // send Game request
    for (Iterator it = team2.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      player.getCom().write(new GameMatch(this));
    }
    for (Iterator it = team1.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      player.getCom().write(new GameMatch(this));
    }
  }
Пример #2
0
 public void handleHeroRespawnRequest(HeroRespawnRequest request) {
   Cell cell = dao.getHeroBeginPosition(request.getHeroSlot());
   cell.setX(cell.getColPos() * Utilizer.TILE_SIZE);
   cell.setY(cell.getRowPos() * Utilizer.TILE_SIZE);
   try {
     request.setRespawnPos(cell.clone());
     for (Iterator it = team2.iterator(); it.hasNext(); ) {
       Player player = (Player) it.next();
       player.getCom().write(request);
     }
     for (Iterator it = team1.iterator(); it.hasNext(); ) {
       Player player = (Player) it.next();
       // if(player.getSlotIndex()!=request.getSlotIndex())
       player.getCom().write(request);
     }
   } catch (CloneNotSupportedException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }