예제 #1
0
  @ReceiveEvent(components = LocalPlayerComponent.class)
  public void onSelectedItemChanged(ChangedComponentEvent event, EntityRef entity) {
    for (UIItemCell cell : toolbar.getCells()) {
      cell.setSelectionRectangleEnable(false);
    }

    LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);
    LocalPlayerComponent localPlayerComp =
        localPlayer.getEntity().getComponent(LocalPlayerComponent.class);
    toolbar.getCells().get(localPlayerComp.selectedTool).setSelectionRectangleEnable(true);
  }
예제 #2
0
  @Override
  public void open() {
    toolbar.setEntity(CoreRegistry.get(LocalPlayer.class).getEntity(), 0, 8);
    layout();

    super.open();
  }
예제 #3
0
  /** Init. the HUD. */
  public UIScreenHUD() {
    maximize();

    _hearts = new UIImage[10];

    // Create hearts
    for (int i = 0; i < 10; i++) {
      _hearts[i] = new UIImage(AssetManager.loadTexture("engine:icons"));
      _hearts[i].setVisible(true);
      _hearts[i].setTextureSize(new Vector2f(9f, 9f));
      _hearts[i].setTextureOrigin(new Vector2f(52f, 0.0f)); // 106f for poison
      _hearts[i].setSize(new Vector2f(18f, 18f));
      _hearts[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      _hearts[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      _hearts[i].setPosition(new Vector2f(18f * i - 212f, -52f));

      addDisplayElement(_hearts[i]);
    }

    crosshair = new UIImage(AssetManager.loadTexture("engine:gui"));
    crosshair.setTextureSize(new Vector2f(20f, 20f));
    crosshair.setTextureOrigin(new Vector2f(24f, 24f));
    crosshair.setSize(new Vector2f(40f, 40f));
    crosshair.setHorizontalAlign(EHorizontalAlign.CENTER);
    crosshair.setVerticalAlign(EVerticalAlign.CENTER);
    crosshair.setVisible(true);

    debugLine1 = new UIText();
    debugLine1.setPosition(new Vector2f(4, 4));
    debugLine2 = new UIText();
    debugLine2.setPosition(new Vector2f(4, 22));
    debugLine3 = new UIText();
    debugLine3.setPosition(new Vector2f(4, 38));
    debugLine4 = new UIText();
    debugLine4.setPosition(new Vector2f(4, 54));

    toolbar = new UIItemContainer(9);
    toolbar.setVisible(true);
    toolbar.setHorizontalAlign(EHorizontalAlign.CENTER);
    toolbar.setVerticalAlign(EVerticalAlign.BOTTOM);

    minionbar = new UIMinionbar();
    minionbar.setVisible(true);

    messagequeue = new UIMessageQueue();
    messagequeue.setVisible(true);

    buffBar = new UIBuff();
    buffBar.setVisible(true);

    addDisplayElement(crosshair, "crosshair");
    addDisplayElement(debugLine1);
    addDisplayElement(debugLine2);
    addDisplayElement(debugLine3);
    addDisplayElement(debugLine4);

    addDisplayElement(toolbar);
    addDisplayElement(minionbar);
    addDisplayElement(messagequeue);
    addDisplayElement(buffBar);

    CoreRegistry.get(EventSystem.class).registerEventHandler(this);

    update();
    layout();
  }