/** * Permet au boss de se déplacer * * @param delta La durée d'une ittération */ @Override public void update(int delta) { if (player.getX() < this.x + aggroRange && player.getX() > this.x - aggroRange && player.getY() < this.y + aggroRange && player.getY() > this.y - aggroRange) { moving = true; aggro = true; } if (moving && knockbackTimer <= 0 && !attaquing) { int relativeX = Math.abs((int) this.x - (int) player.getX()), relativeY = Math.abs((int) this.y - (int) player.getY()); if (this.x < player.getX() && relativeX > relativeY) { this.direction = 3; } else if (this.x > player.getX() && relativeX > relativeY) { this.direction = 1; } else if (this.y < player.getY() && relativeY > relativeX) { this.direction = 2; } else if (this.y > player.getY() && relativeY > relativeX) { this.direction = 0; } if (!map.isCollision(futurX(delta), futurY(delta))) { this.x = futurX(delta); this.y = futurY(delta); } this.attack(); } else if (knockbackTimer > 0) { moving = true; float tempSpeed = speed; speed = 0.5f; if (!map.isCollision(futurX(-delta), futurY(-delta))) { this.x = futurX(-delta); this.y = futurY(-delta); } speed = tempSpeed; knockbackTimer -= delta; } else if (attCounter > 0 && attaquing) { attCounter -= delta; if (attCounter <= 0) { attaquing = false; xOff = -16; yOff = -60; hitBox = new Box(x + xOff, y + yOff, 32, 60); } } if (attCooldown > 0) { attCooldown -= delta; } hitBox.setPos(x + xOff, y + yOff); }