Package games.stendhal.common

Examples of games.stendhal.common.Direction


    }
    if (diff.has("y")) {
      newY = diff.getInt("y");
    }

    Direction temp_direction;

    if (diff.has("dir")) {
      temp_direction = Direction.build(diff.getInt("dir"));
      setDirection(temp_direction);
      fireChange(PROP_DIRECTION);
View Full Code Here


      player.sendPrivateText("Although you have heard a lot of rumors about the destination, "
                + "you cannot join " + spouseName + " there because it is still an unknown place for you.");
      return false;
    }

    final Direction dir = spouse.getDirection();

    if (player.teleport(destinationZone, x, y, dir, player)) {
      storeLastUsed();
      return true;
    }
View Full Code Here

    case KeyEvent.VK_UP:
    case KeyEvent.VK_DOWN:
      /*
       * Ctrl means face, otherwise move
       */
      final Direction direction = keyCodeToDirection(e.getKeyCode());

      if (e.isAltGraphDown()) {
        final User user = User.get();

        final EntityView view = screen.getEntityViewAt(user.getX()
            + direction.getdx(), user.getY() + direction.getdy());

        if (view != null) {
          final IEntity entity = view.getEntity();
          if (!entity.equals(user)) {
            view.onAction();
View Full Code Here

    action.put("x", (int) point.getX());
    action.put("y", (int) point.getY());
    if (doubleClick) {
      action.put("double_click", "");
    }
    Direction dir = calculateZoneChangeDirection(point);
    if (dir != null) {
      action.put("extend", dir.ordinal());
    }
    client.send(action);
  }
View Full Code Here

     * Turning with mouse wheel. Ignore all but the first to avoid flooding
     * the server with turn commands.
     */
    logger.debug(e.getClickCount() + " click count and " + e.getScrollType() + " scroll type and wheel rotation " + e.getWheelRotation());
    if (e.getClickCount() <= 1) {
      Direction current = User.get().getDirection();
      if (e.getUnitsToScroll() > 0) {
        // Turn right
        client.addDirection(current.nextDirection(), true);
      } else {
        // Turn left
        client.addDirection(current.nextDirection().oppositeDirection(), true);
      }
    }
  }
View Full Code Here

      boolean keepRunning = true;
      counter++;
      if (beamed) {
        // slow down
        if (counter % inversedSpeed == 0) {
          Direction direction = player.getDirection();
          direction = Direction.build((direction.get()) % 4 + 1);
          player.setDirection(direction);
          sandbox.modify(player);
          if (direction == Direction.DOWN) {
            inversedSpeed++;
            if (inversedSpeed == 3) {
              keepRunning = false;
            }
          }
        }
      } else {
        // speed up
        if (counter % inversedSpeed == 0) {
          Direction direction = player.getDirection();
          direction = Direction.build((direction.get()) % 4 + 1);
          player.setDirection(direction);
          sandbox.modify(player);
          if (direction == Direction.DOWN) {
            switch (textCounter) {
            case 0:
View Full Code Here

   *            Stop movement if no (valid) directions are active if
   *            <code>true</code>.
   */
  public void applyClientDirection(final boolean stopOnNone) {
    int size;
    Direction direction;

    /*
     * For now just take last direction.
     *
     * Eventually try each (last-to-first) until a non-blocked one is found
     * (if any).
     */
    size = directions.size();
    if (size != 0) {
      direction = directions.get(size - 1);

      // as an effect of the poisoning, the player's controls
      // are switched to make it difficult to navigate.
      if (isPoisoned()) {
        direction = direction.oppositeDirection();
      }

      setDirection(direction);
      setSpeed(getBaseSpeed());
    } else if (stopOnNone) {
View Full Code Here

        }
       
        if (weWouldLeaveArea(creature, Direction.STOP)) {
          initArea(creature);
        }
        Direction currentDir = creature.getDirection();
        if ((currentDir == Direction.STOP)
            || weWouldLeaveArea(creature, creature.getDirection())
            || creature.getZone().collides(creature, creature.getX() + currentDir.getdx(),
                creature.getY() + currentDir.getdy())) {
          for (int i = 0; i < 4; i++) {
            currentDir = currentDir.nextDirection();

            if (!weWouldLeaveArea(creature, currentDir)
                && !creature.getZone().collides(creature, creature.getX() + currentDir.getdx(),
                    creature.getY() + currentDir.getdy())) {
              creature.setDirection(currentDir);
              continue;
            }
          }
        }
View Full Code Here

   * @param face
   *            If to face direction only.
   */
  public void addDirection(final Direction dir, final boolean face) {
    RPAction action;
    Direction odir;
    int idx;

    /*
     * Cancel existing opposite directions
     */
    odir = dir.oppositeDirection();

    if (directions.remove(odir)) {
      /*
       * Send direction release
       */
      action = new RPAction();
      action.put("type", "move");
      action.put("dir", -odir.get());

      send(action);
    }

    /*
 
View Full Code Here

      return;
    }
    if (!action.has("extend")) {
      return;
    }
    Direction dir = Direction.build(action.getInt("extend"));
    Node lastNode = path.get(path.size() - 1);
    path.add(new Node(lastNode.getX() + dir.getdx(), lastNode.getY() + dir.getdy()));
  }
View Full Code Here

TOP

Related Classes of games.stendhal.common.Direction

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.