Esempio n. 1
0
  @Override
  public void handleDataClicked(final Object data, InputEvent event, float x, float y) {
    {
      if (GameScreen.Instance.abilityToEquip != null) {
        int index = 0;
        if (data instanceof Integer) {
          index = (Integer) data;
        } else {
          index = Global.CurrentLevel.player.slottedAbilities.indexOf((AbilityTree) data, true);
        }

        while (Global.CurrentLevel.player.slottedAbilities.size <= index) {
          Global.CurrentLevel.player.slottedAbilities.add(null);
        }

        Global.CurrentLevel.player.slottedAbilities.removeIndex(index);
        Global.CurrentLevel.player.slottedAbilities.insert(
            index, GameScreen.Instance.abilityToEquip);
        GameScreen.Instance.abilityToEquip = null;

        if (data instanceof AbilityTree) {
          Item item = new Item();
          item.ability = (AbilityTree) data;

          Global.CurrentLevel.player.tile[0][0].items.add(item);
        }

        GameScreen.Instance.lockContextMenu = false;
        GameScreen.Instance.clearContextMenu();
      } else {
        if (data instanceof AbilityTree
            && ((AbilityTree) data).current.current instanceof ActiveAbility) {
          ActiveAbility aa = (ActiveAbility) ((AbilityTree) data).current.current;

          if (GameScreen.Instance.preparedAbility == aa) {
            GameScreen.Instance.prepareAbility(null);
          } else if (aa.isAvailable()) {
            GameScreen.Instance.prepareAbility(aa);
          }
        }
      }
    }
  }
Esempio n. 2
0
  @Override
  public void onDrawItem(Object data, Batch batch, int x, int y, int width, int height) {
    if (data instanceof AbilityTree
        && ((AbilityTree) data).current.current instanceof ActiveAbility) {
      ActiveAbility aa = (ActiveAbility) ((AbilityTree) data).current.current;

      if (!aa.isAvailable()) {
        batch.setColor(0.1f, 0.1f, 0.1f, 0.75f);
        batch.draw(white, x, y, width, height);
        batch.setColor(Color.WHITE);

        int cooldown = (int) Math.ceil(aa.cooldownAccumulator);

        if (cooldown > 0) {
          String text = aa.cooldownType.text + "\n" + cooldown;
          layout.setText(font, text, Color.WHITE, 0, Align.center, false);

          font.draw(batch, layout, x + width / 2, y + height / 2 + layout.height / 2);
        }
      }
    }
  }