예제 #1
0
 public Player getPlayerById(int playerId) {
   for (Player player : players) {
     if (player.getId() == playerId) {
       return player;
     }
   }
   return null;
 }
예제 #2
0
 private void respawnDeadPlayers() {
   for (Player player : players) {
     if (!player.isAlive()) {
       spawnPlayer(player);
       player.setHp(Unit.MAX_HP);
     }
   }
 }
예제 #3
0
 private void spawnPlayer(Player player) {
   int randomIndex = (int) (Math.random() * spawns.size());
   Spawn spawn = spawns.get(randomIndex);
   player.getPosition().setX(spawn.getPosition().getX());
   player.getPosition().setY(spawn.getPosition().getY());
 }