Package games.stendhal.client.entity

Examples of games.stendhal.client.entity.RPEntity


    final int barWidth = Math.max(width * 2 / 3, IGameScreen.SIZE_UNIT_PIXELS);

    final int bx = x + ((width - barWidth) / 2);
    final int by = y - 3;

    RPEntity rpentity = (RPEntity) entity;
   
    final float hpRatio = rpentity.getHpRatio();

    final float r = Math.min((1.0f - hpRatio) * 2.0f, 1.0f);
    final float g = Math.min(hpRatio * 2.0f, 1.0f);

    g2d.setColor(Color.gray);
View Full Code Here


   * @param height
   *            The drawn entity height.
   */
  protected void drawIdeas(final Graphics2D g2d, final int x,
      final int y, final int height) {
    RPEntity rpentity = (RPEntity) entity;
   
    if (rpentity.isEating()) {
      if (rpentity.isChoking()) {
        chokingSprite.draw(g2d, x, y + height - 2 * ICON_OFFSET);
      } else {
        eatingSprite.draw(g2d, x, y + height - 2 * ICON_OFFSET);
      }
    }

    if (rpentity.isPoisoned()) {
      poisonedSprite.draw(g2d, x - ICON_OFFSET, y + height - 2 * ICON_OFFSET);
    }
  }
 
View Full Code Here

   * @param height
   *            The drawn entity height.
   */
  protected void drawCombat(final Graphics2D g2d, final int x,
                final int y, final int width, final int height) {
    RPEntity rpentity = (RPEntity) entity;
   
    Rectangle2D wrect = rpentity.getArea();
    final Rectangle srect = new Rectangle((int) (wrect.getX() * IGameScreen.SIZE_UNIT_PIXELS),
        (int) (wrect.getY() * IGameScreen.SIZE_UNIT_PIXELS),
        (int) (wrect.getWidth() * IGameScreen.SIZE_UNIT_PIXELS),
        (int) (wrect.getHeight() * IGameScreen.SIZE_UNIT_PIXELS));
   
    final double DIVISOR = 1.414213562; // sqrt(2)
   
    if (rpentity.isBeingAttacked()) {
      // Draw red box around
      //g2d.setColor(Color.white);
      //g2d.drawRect(srect.x + 1, srect.y + 1, srect.width - 2, srect.height - 2);
      g2d.setColor(Color.red);
      int circleHeight = (int) ((srect.height - 2) / DIVISOR);
      // Avoid showing much smaller area than the creature covers
      circleHeight = Math.max(circleHeight, srect.height - IGameScreen.SIZE_UNIT_PIXELS / 2);
      g2d.drawArc(srect.x, (int) (srect.y + srect.height - circleHeight),
          srect.width + 0, circleHeight, 0, 360);
    }

    if (rpentity.isAttacking(User.get())) {
      // Draw orange box around
      //g2d.setColor(Color.white);
      //g2d.drawRect(srect.x + 2, srect.y + 2, srect.width - 4, srect.height - 4);
      g2d.setColor(Color.orange);
      int circleHeight = (int) ((srect.height - 4) / DIVISOR);
      // Avoid showing much smaller area than the creature covers
      circleHeight = Math.max(circleHeight, srect.height - IGameScreen.SIZE_UNIT_PIXELS / 2 - 2);
      g2d.drawArc(srect.x + 1, (int) (srect.y + srect.height - circleHeight - 1),
          srect.width - 2, circleHeight, 0, 360);
    }

    drawAttack(g2d, x, y, width, height);

    if (rpentity.isDefending()) {
      // Draw bottom right combat icon
      final int sx = srect.x + srect.width - ICON_OFFSET;
      final int sy = y + height - 2 * ICON_OFFSET;

      switch (rpentity.getResolution()) {
      case BLOCKED:
        blockedSprite.draw(g2d, sx, sy);
        break;

      case MISSED:
View Full Code Here

   * @param y y coordinate of the attacker
   * @param width width of the attacker
   * @param height height of the attacker
   */
  private void drawAttack(final Graphics2D g2d, final int x, final int y, final int width, final int height) {
    RPEntity rpentity = (RPEntity) entity;
   
    if (rpentity.isAttacking() && rpentity.getShownDamageType() != null) {
      if (frameBladeStrike < NUM_ATTACK_FRAMES) {
        RPEntity target = rpentity.getAttackTarget();

        // A hack to check if it's a distance attack for proof
        // of concept arrow drawing. Should be specified in the
        // attack event itself
        final Rectangle2D area = rpentity.getArea();
        area.setRect(rpentity.getX() - 0.25, rpentity.getY() - 0.25, rpentity.getWidth()
            + 2 * 0.25, rpentity.getHeight() + 2 * 0.25);
       
        if (area.intersects(target.getArea())) {
          drawStrike(g2d, rpentity, x, y, width, height);
        } else {
          drawDistanceAttack(g2d, rpentity, target, x, y, width, height);
        }
        frameBladeStrike++;
View Full Code Here

   */
  @Override
  protected void buildActions(final List<String> list) {
    super.buildActions(list);

    RPEntity rpentity = (RPEntity) entity;
    if (rpentity.isAttackedBy(User.get())) {
      list.add(ActionType.STOP_ATTACK.getRepresentation());
    } else {
      list.add(ActionType.ATTACK.getRepresentation());
    }

View Full Code Here

  }
 
  @Override
  protected AlphaComposite getComposite() {
    // Check for ghostmode to avoid ignored ghostmode admins becoming visible
    RPEntity rpentity = (RPEntity) entity;
    if (User.isIgnoring(rpentity.getName()) && !rpentity.isGhostMode()) {
      return AlphaComposite.DstOut;
    }
    return super.getComposite();
  }
View Full Code Here

   * @param list
   *            The list to populate.
   */
  @Override
  protected void buildActions(final List<String> list) {
    RPEntity player = (RPEntity) entity;
    if (!player.isGhostMode()) {
      super.buildActions(list);
     
      boolean hasBuddy = User.hasBuddy(player.getName());
      if (!hasBuddy) {
        list.add(ActionType.ADD_BUDDY.getRepresentation());
      }
     
      if (User.isIgnoring(player.getName())) {
        list.add(ActionType.UNIGNORE.getRepresentation());
      } else if (!hasBuddy)  {
        list.add(ActionType.IGNORE.getRepresentation());
      }
      String serverVersion = User.getServerRelease();
View Full Code Here

    } catch (ArrayIndexOutOfBoundsException exc) {
      logger.warn("Unknown damage type: " + idx);
      dtype = Nature.CUT;
    }
   
    RPEntity target = entity.getAttackTarget();
    if (target != null) {
      if (event.has("hit")) {
        int damage = event.getInt("damage");
        if (damage != 0) {
          entity.onAttackDamage(dtype);
          target.onDamaged(entity, damage);
        } else {
          entity.onAttackBlocked(dtype);
          target.onBlocked(entity);
        }
      } else {
        entity.onAttackMissed(dtype);
        target.onMissed(entity);
      }
    }
  }
View Full Code Here

TOP

Related Classes of games.stendhal.client.entity.RPEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.