コード例 #1
0
ファイル: GameKeyHandler.java プロジェクト: Tomy1use/stendhal
  /** Process delayed direction release. */
  synchronized void processDelayedDirectionRelease() {
    if ((directionRelease != null) && directionRelease.hasExpired()) {
      client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing());

      directionRelease = null;
    }
  }
コード例 #2
0
ファイル: GameKeyHandler.java プロジェクト: Tomy1use/stendhal
  /**
   * Handle direction release actions.
   *
   * @param direction The direction.
   * @param facing If facing only.
   */
  private synchronized void processDirectionRelease(
      final Direction direction, final boolean facing) {
    if (directionRelease != null) {
      if (directionRelease.check(direction, facing)) {
        /*
         * Ignore repeats
         */
        return;
      } else {
        /*
         * Flush previous release
         */
        client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing());
      }
    }

    directionRelease = new DelayedDirectionRelease(direction, facing);
  }
コード例 #3
0
ファイル: GameKeyHandler.java プロジェクト: Tomy1use/stendhal
  /**
   * Handle direction press actions.
   *
   * @param direction The direction.
   * @param facing If facing only.
   */
  private synchronized void processDirectionPress(final Direction direction, final boolean facing) {
    if (directionRelease != null) {
      if (directionRelease.check(direction, facing)) {
        directionRelease = null;
        return;
      } else {
        /*
         * Flush pending release
         */
        client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing());

        directionRelease = null;
      }
    }

    if (client.addDirection(direction, facing)) {
      // Movement prediction.
      User user = User.get();
      if (user != null) {
        user.predictMovement(direction, facing);
      }
    }
  }