public void damageEntity() { for (Entity e : handler.getGame().geteManager().getEntities()) { if (getAttackBounds(0, 0).intersects(e.getCollisionBounds(0, 0))) { if (e.equals(this)) continue; else if (e instanceof Monster) { Creature c = ((Creature) e); c.takeDamage(damage); if (c.getHealth() > 0) c.setKnockBack(x, y, knockBack); lastTarget = target; target = null; } } } }
@Override public void update() { if (state == "DESTROY") destroy(); else if (shadowIn.isComplete()) { if (health <= 0) destroy(); xMove = 0; yMove = 0; player = handler.getGame().geteManager().getPlayer(); if (target == null) { findDesiredLocs(); moveTo(desLocX, desLocY); } else { moveTo(target.getCenterPosX(), target.getCenterPosY()); } reachRect = new Rectangle( (int) (x + width / 2 - reach * Tile.TILE_WIDTH / 2 - handler.getCamera().getxOffset()), (int) (y + height / 2 - reach * Tile.TILE_HEIGHT / 2 - handler.getCamera().getyOffset()), reach * Tile.TILE_WIDTH, reach * Tile.TILE_HEIGHT); taggedEntities.removeAll(taggedEntities); for (Entity e : handler.getGame().geteManager().getEntities()) { if (e instanceof ShadowPuppet) { if (((ShadowPuppet) e).getTarget() != null) { taggedEntities.add(e); } } } for (Entity e : handler.getGame().geteManager().getEntities()) { if (!(e instanceof Monster)) continue; if (e instanceof ShadowPuppet || taggedEntities.contains(e)) continue; if (e == lastTarget) continue; if (e.getCollisionBounds( -handler.getCamera().getxOffset(), -handler.getCamera().getyOffset()) .intersects(reachRect)) { target = e; } } if (target != null && !(reachRect.intersects( target.getCollisionBounds( -handler.getCamera().getxOffset(), -handler.getCamera().getyOffset())))) { target = null; lastTarget = null; } setCurrentAnimation(); damageEntity(); move(); } if (currentAnimation != null) currentAnimation.update(); }