Пример #1
0
  public void showShieldBuff() {
    final Image shieldBuff = new Image(AssetLoader.uiAtlas.findRegion("shield"));
    final Label shieldTime = new Label("60:00s", Skins.xSmallTxt);
    Stack shieldBuffStack = new Stack();
    shieldBuffStack.add(shieldBuff);
    Table shieldTimeTbl = new Table();
    shieldTimeTbl.add(shieldTime).expand().bottom().left().pad(3);
    shieldBuffStack.add(shieldTimeTbl);

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

    GdxGame.hud_stage.addActor(shieldBuffTbl);
    actionManager.addAction(
        repeat(
            GameData.shieldDuration(),
            sequence(
                delay(1f),
                run(
                    new Runnable() {
                      @Override
                      public void run() {
                        GameData.setShieldDuration(GameData.shieldDuration() - 1);
                        if (GameData.shieldDuration() <= 0) {
                          GameData.setVillageShield(false);
                          shieldBuffTbl.remove();
                        }
                        String timer = SEG2HOR(GameData.shieldDuration());
                        shieldTime.setText(timer + "s");
                      }
                    }))));
  }
Пример #2
0
  public SelectSkill(
      final Label villageHp,
      final Image villageHpBar,
      final Label mana,
      final Image manaBar,
      final Lobby lobby) {
    this.villageHp = villageHp;
    this.villageHpBar = villageHpBar;
    this.mana = mana;
    this.manaBar = manaBar;
    this.lobby = lobby;
    actionManager = new Actor();
    GdxGame.hud_stage.addActor(actionManager);
    mana20 = MathUtils.round(GameData.maxMana() * 0.2f);
    mana10 = MathUtils.round(GameData.maxMana() * 0.1f);
    mana5 = MathUtils.round(GameData.maxMana() * 0.05f);
    hp10 = MathUtils.round(GameData.maxVillageHp() * 0.1f);

    notifTxt = new Label("", Skins.mediumTxt);
    // Create reuseable function for label notif text
    // lock shield and one hit skills
  }
Пример #3
0
 public void shieldReady() {
   if (GameData.villageShield()) {
     Gdx.app.log("Seconds", lobby.timepassed + "");
     minusDur = lobby.seconds - GameData.logInTime();
     GameData.setShieldDuration(GameData.shieldDuration() - (int) lobby.timepassed);
     if (GameData.shieldDuration() > 0) {
       showShieldBuff();
     } else {
       GameData.setVillageShield(false);
     }
   }
 }
Пример #4
0
  public void showSkills() {
    healBtn = new ImgButton(Skins.healBtn);
    healBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            healVillage();
            if (Tutorial.name("heal")) {
              lobby.tutorDialog.nextDialog();
            }
          }
        });
    shieldBtn = new ImgButton(Skins.shieldBtn);
    shieldBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            if (GameData.level() >= 5) {
              shieldVillage();
            } else {
              showNotif("Unlock this skill at Level 5");
            }
          }
        });
    if (GameData.level() < 5) {
      shieldBtn.setDisabled(true);
    } else {
      shieldBtn.setDisabled(false);
    }
    oneHitBtn = new ImgButton(Skins.oneHitBtn);
    oneHitBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            if (GameData.level() >= 10) {
              oneHitSkill();
            } else {
              showNotif("Unlock this skill at Level 10");
            }
          }
        });
    if (GameData.level() < 10) {
      oneHitBtn.setDisabled(true);
    } else {
      oneHitBtn.setDisabled(false);
    }

    healInfoBtn = new ImgButton(Skins.infoBtn);
    healInfoBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            new GameInfo(
                "Heal\n\nRestores the village health by 10%. Consumes " + healMana + " mana.");
          }
        });

    shieldInfoBtn = new ImgButton(Skins.infoBtn);
    shieldInfoBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            new GameInfo(
                "Shield\n\nProtects the village from lost souls damage for 1 hour. Consumes "
                    + shieldMana
                    + " mana.");
          }
        });

    oneHitInfoBtn = new ImgButton(Skins.infoBtn);
    oneHitInfoBtn.addListener(
        new ClickListener() {
          public void clicked(InputEvent event, float x, float y) {
            new GameInfo(
                "Bull's Eye\n\nEliminate a ghost by a single tap for 30 seconds. Consumes "
                    + oneHitMana
                    + " mana.");
          }
        });

    table = new Table();
    table.setTransform(true);
    table.setBounds(0, 0, Resize.getWidth(), Resize.getHeight());
    // table.add(new Image(AssetLoader.uiAtlas.findRegion("")));
    Table rightTable = new Table();
    rightTable.setSize(345, 115);

    Stack healInfoStack = new Stack();
    healInfoStack.add(healBtn);
    Table healTbl = new Table();
    healTbl.add(healInfoBtn).size(40, 40).expand().right().top().pad(3);
    healInfoStack.add(healTbl);
    rightTable.add(healInfoStack).size(95, 95).pad(10);

    Stack shieldInfoStack = new Stack();
    shieldInfoStack.add(shieldBtn);
    Table shieldTbl = new Table();
    shieldTbl.add(shieldInfoBtn).size(40, 40).expand().right().top().pad(3);
    shieldInfoStack.add(shieldTbl);
    rightTable.add(shieldInfoStack).size(95, 95).pad(10);

    Stack oneHitInfoStack = new Stack();
    oneHitInfoStack.add(oneHitBtn);
    Table oneHitTbl = new Table();
    oneHitTbl.add(oneHitInfoBtn).size(40, 40).expand().right().top().pad(3);
    oneHitInfoStack.add(oneHitTbl);
    rightTable.add(oneHitInfoStack).size(95, 95).pad(10);
    table.add(rightTable).expand().bottom().right().padRight(110);
    // table.debug();
  }
Пример #5
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.");
    }
  }
Пример #6
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.");
    }
  }
Пример #7
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.");
    }
  }