Exemplo n.º 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));
    }
  }
Exemplo n.º 2
0
 public void createMonsters() {
   MonsterFactory mF = new MonsterFactory();
   ArrayList<Cell> t = new ArrayList<Cell>(dao.getAllMonsterPositions());
   int index = 1;
   for (Iterator it = t.iterator(); it.hasNext(); ) {
     Monster monster = mF.createMonster(index);
     index++;
     if (index > 3) index = 1;
     Cell cell = (Cell) it.next();
     monster.setRow(cell.getRowPos());
     monster.setCol(cell.getColPos());
     monster.setX(cell.getColPos() * Utilizer.TILE_SIZE);
     monster.setY(cell.getRowPos() * Utilizer.TILE_SIZE);
     monsters.add(monster);
   }
 }
Exemplo n.º 3
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.
   }
 }