Пример #1
0
  @Override
  public boolean checkMobParticleHit(Particle p) {
    if (gameController.multiplayerMode != gameController.multiplayerMode.CLIENT) {
      Monster monster = null;

      try {
        for (String key : monsters.keySet()) {
          monster = (Monster) monsters.get(key);
          if (monster.getPerimeter().intersects(p.getRect())) {
            monster.applyDamage(p.getDamage(), p.getSource(), p.isFromPlaceable(), false);
            return true;
          }
        }
      } catch (ConcurrentModificationException concEx) {
        // another thread was trying to modify monsters while iterating
        // we'll continue and the new item can be grabbed on the next update
      }
    }

    return false;
  }
Пример #2
0
 public void processMonsterUpdate(UpdateMonster um) {
   if (um != null) {
     if (monsters.containsKey(um.id)) {
       Monster monster = monsters.get(um.id);
       if (monster != null) {
         EIError.debugMsg(
             "Setting " + um.id + " to " + um.mapX + ":" + um.mapY + ", Action: " + um.action);
         monster.setPosition(um.mapX, um.mapY);
         if (um.previousGoal != null) {
           monster.ai.setPreviousGoal(um.previousGoal);
         }
         if (um.currentGoal != null) {
           monster.ai.setCurrentGoal(um.currentGoal);
         }
         if (um.action.equals("ApplyDamage")) {
           monster.applyDamage(um.dataInt, um.actor);
         } else if (um.action.equals("ApplyKnockBack")) {
           monster.applyKnockBack(um.dataInt, um.dataInt2);
         } else if (um.action.equals("Die")) {
           monster.setHitPoints(0);
         } else if (um.action.equals("Fear")) {
           monster.applyKnockBack(um.dataInt, um.dataInt2);
           monster.fear(um.dataPoint, um.dataLong);
         }
       }
     } else {
       if (gameController.multiplayerMode == gameController.multiplayerMode.CLIENT
           && registry.getNetworkThread() != null) {
         if (registry.getNetworkThread().readyForUpdates()) {
           EIError.debugMsg("Monster not found - need " + um.id);
           registry.getNetworkThread().sendData("send monster data: " + um.id);
         }
       }
     }
   }
 }