Exemplo n.º 1
0
  public void shieldVillage() {
    if (GameData.villageShield()) {
      showNotif("Shield is already activated.");
    } else if (shieldMana <= GameData.mana()) {
      Sfx.playShield();
      GameData.setVillageShield(true);
      GameData.setShieldDuration(3600);
      showShieldBuff();

      if (GameData.mana() - shieldMana < 0) {
        GameData.setMana(0);
        manaBar.addAction(scaleTo(0f, 1f, 1f));
      } else {
        GameData.setMana(GameData.mana() - shieldMana);
        lobby.updateLabels();
      }
      mana.setText(GameData.mana() + "/" + GameData.maxMana());

      closeUi();

    } else {
      showMagicAd();
      int neededMana = shieldMana - GameData.mana();
      showNotif("Need " + neededMana + " more mana.");
    }
  }
Exemplo n.º 2
0
  public void healVillage() {
    if (GameData.villageHp() >= GameData.maxVillageHp()) {
      showNotif("Your Village Health is full.");
    } else if (healMana <= GameData.mana()) {
      Sfx.playHeal();
      healed = true;
      if (hp10 + GameData.villageHp() > GameData.maxVillageHp()) {
        GameData.setVillageHp(GameData.maxVillageHp());
        // villageHpBar.addAction(scaleTo(1f, 1f, 1f));
      } else {
        GameData.setVillageHp(GameData.villageHp() + hp10);
        // villageHpBar.addAction(scaleBy(0.1f, 0f, 1f));
      }
      if (GameData.mana() - healMana < 0) {
        GameData.setMana(0);
        manaBar.addAction(scaleTo(0f, 1f, 1f));
      } else {
        GameData.setMana(GameData.mana() - healMana);
        lobby.updateLabels();
      }
      mana.setText(GameData.mana() + "/" + GameData.maxMana());
      // villageHp.setText(GameData.villageHp() + "/" + GameData.maxVillageHp());

      closeUi();
    } else {
      showMagicAd();
      int neededMana = healMana - GameData.mana();
      showNotif("Need " + neededMana + " more mana.");
    }
  }
Exemplo n.º 3
0
  public void oneHitSkill() {
    if (oneHitMana <= GameData.mana()) {
      Sfx.playWind();
      oneTapKo = true;
      oneTapDuration = 30;
      final Image oneTapBuff = new Image(AssetLoader.uiAtlas.findRegion("one-hit"));
      final Label oneTapBuffTime = new Label(oneTapDuration + "s", Skins.xSmallTxt);
      Stack oneTapBuffStack = new Stack();
      oneTapBuffStack.add(oneTapBuff);
      Table oneTapBuffTimeTbl = new Table();
      oneTapBuffTimeTbl.add(oneTapBuffTime).expand().bottom().left().pad(3);
      oneTapBuffStack.add(oneTapBuffTimeTbl);

      final Table oneTapBuffTbl = new Table();
      oneTapBuffTbl.setTransform(true);
      oneTapBuffTbl.setBounds(0, 0, Resize.getWidth(), Resize.getHeight());
      oneTapBuffTbl
          .add(oneTapBuffStack)
          .size(60, 60)
          .expand()
          .right()
          .top()
          .padTop(140)
          .padRight(10);

      GdxGame.hud_stage.addActor(oneTapBuffTbl);
      actionManager.addAction(
          repeat(
              30,
              sequence(
                  delay(1f),
                  run(
                      new Runnable() {
                        @Override
                        public void run() {
                          oneTapDuration--;
                          if (oneTapDuration <= 0) {
                            oneTapKo = false;
                            oneTapBuffTbl.remove();
                          }
                          oneTapBuffTime.setText(oneTapDuration + "s");
                        }
                      }))));

      actionManager.addAction(
          sequence(
              delay(30f),
              run(
                  new Runnable() {
                    @Override
                    public void run() {
                      oneTapKo = false;
                      oneTapBuffTbl.remove();
                    }
                  })));

      if (GameData.mana() - oneHitMana < 0) {
        GameData.setMana(0);
        manaBar.addAction(scaleTo(0f, 1f, 1f));
      } else {
        GameData.setMana(GameData.mana() - oneHitMana);
        lobby.updateLabels();
      }
      mana.setText(GameData.mana() + "/" + GameData.maxMana());

      closeUi();
    } else {
      showMagicAd();
      int neededMana = oneHitMana - GameData.mana();
      showNotif("Need " + neededMana + " more mana.");
    }
  }