Пример #1
0
  /**
   * Update the display entries.
   *
   * @param container the container that holds the game
   * @param delta the time in milliseconds since the last update
   */
  public void update(@Nonnull GameContainer container, int delta) {
    if (!active) {
      return;
    }

    int centerX = container.getWidth() >> 1;
    int centerY = container.getHeight() >> 1;

    int offX = (centerX - origin.getDcX()) + dX;
    int offY = (centerY - origin.getDcY()) + dY - dL;

    Avatar av = World.getPlayer().getCharacter().getAvatar();
    if (av != null) {
      glueAvatarToOrigin(av);
      corridor.setCorridor(av);
    }

    Camera.getInstance().setViewport(-offX, -offY, container.getWidth(), container.getHeight());

    Input engineInput = container.getEngine().getInput();
    gameScene.publishEvent(
        new CurrentMouseLocationEvent(engineInput.getMouseX(), engineInput.getMouseY()));
    gameScene.update(container, delta);
    updateFog(container);
    updateDeadView(container);
  }
Пример #2
0
  /**
   * Show spoken text as tooltip
   *
   * @param text
   * @param mode
   */
  public void showText(final String text, final int mode, final int x, final int y) {
    // convert to screen coordinates
    final Location tempLoc = new Location();
    tempLoc.setSC(x, y, origin.getScZ());

    sayText(tempLoc.getDcX(), tempLoc.getDcY(), text, mode);
  }
Пример #3
0
  public void update(final GameContainer c, final int delta) {
    if (!active) {
      return;
    }

    final int centerX = c.getWidth() >> 1;
    final int centerY = c.getHeight() >> 1;

    final int offX = (centerX - origin.getDcX()) + dX;
    final int offY = (centerY - origin.getDcY()) + dY;

    final Avatar av = World.getAvatar();
    if (av != null) {
      glueAvatarToOrigin(av);
      corridor.setCorridor(av);
    }

    Camera.getInstance().setViewport(-offX, -offY, c.getWidth(), c.getHeight());
    Camera.getInstance().clearDirtyAreas();

    if (legacyRendering) {
      Camera.getInstance().markEverythingDirty();
    }

    synchronized (display) {
      for (final Rectangle rect : removedAreaList) {
        Camera.getInstance().markAreaDirty(rect);
      }
      synchronized (GameMap.LIGHT_LOCK) {
        while (true) {
          final MapInteractionEvent event = eventQueue.poll();
          if (event == null) {
            break;
          }

          for (int i = display.size() - 1; i >= 0; i--) {
            if (display.get(i).processEvent(c, delta, event)) {
              break;
            }
          }
        }

        // update the items
        for (int i = 0, displaySize = display.size(); i < displaySize; i++) {
          display.get(i).update(c, delta);
        }
      }
    }

    if (fadeOutColor.getAlpha() > 0) {
      fadeOutColor.a = AnimationUtility.approach(fadeOutColor.getAlpha(), 0, 0, 255, delta) / 255.f;
    }
  }
Пример #4
0
  /**
   * Display lookat text
   *
   * @param x screen coordinates
   * @param y
   * @param text
   */
  public void lookAt(int x, int y, final String text) {
    x += (getMapCenterX() - origin.getDcX()) + dX;
    y += (getMapCenterY() - origin.getDcY()) + dY;
    // y += MAP_CENTER_Y + dY;

    // Tooltip tip = Tooltip.create();
    // tip.initText(text);
    // tip.show(x, y + MapConstants.TILE_H);
    // tip.setColor(Colors.white);
    // Gui.getInstance().addToolTip(tip);

  }
Пример #5
0
  /**
   * Move the map origin to a new location
   *
   * @param location
   */
  public void setLocation(@Nonnull Location location) {
    origin.set(location);
    elevation = World.getMap().getElevationAt(origin);
    dX = 0;
    dY = 0;
    dL = -elevation;

    World.getMap().getMiniMap().setPlayerLocation(location);
  }
Пример #6
0
 /**
  * Get the data of this talking message as string.
  *
  * @return the string that contains the values that were decoded for this message
  */
 @SuppressWarnings("nls")
 @Override
 public String toString() {
   final StringBuilder builder = new StringBuilder();
   builder.append("at ");
   builder.append(loc.toString());
   builder.append(" \"");
   builder.append(text);
   builder.append('"');
   return toString(builder.toString());
 }
Пример #7
0
 /**
  * Move the map origin to a new location
  *
  * @param location
  */
 public void setLocation(final Location location) {
   // origin.setSC(location.scX, location.scY, 0);
   origin.set(location);
   ani.stop();
   final Avatar avatar = World.getAvatar();
   if (avatar != null) {
     avatar.animationFinished(false);
   }
   elevation = World.getMap().getElevationAt(origin);
   dX = 0;
   dY = 0;
   dL = -elevation;
   Camera.getInstance().markEverythingDirty();
 }
Пример #8
0
 /**
  * Fix avatar's position in the middle of the screen and Z-Order
  *
  * @param av
  */
 public void glueAvatarToOrigin(final Avatar av) {
   av.setScreenPos(
       origin.getDcX() - dX, (origin.getDcY() - dY) + dL, origin.getDcZ(), Layers.CHARS);
 }
Пример #9
0
 public int getWorldY(final int y) {
   return ((y - getMapCenterY()) + origin.getDcY()) - dY;
 }
Пример #10
0
 public int getWorldX(final int x) {
   return ((x - getMapCenterX()) + origin.getDcX()) - dX;
 }
Пример #11
0
 /**
  * Fix avatar's position in the middle of the screen and Z-Order
  *
  * @param av
  */
 public void glueAvatarToOrigin(@Nonnull Avatar av) {
   av.setScreenPos(origin.getDcX() - dX, (origin.getDcY() - dY) + dL, origin.getDcZ());
 }
 @Override
 public void setTarget(@Nonnull final Location loc) {
   targetLocation.set(loc);
 }
 /**
  * Update the angle of arrow.
  *
  * @param delta the time since the last update
  */
 void update(final int delta) {
   currentDeltaX = targetLocation.getScX() - World.getPlayer().getLocation().getScX();
   currentDeltaY = targetLocation.getScY() - World.getPlayer().getLocation().getScY();
 }