Ejemplo n.º 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");
                      }
                    }))));
  }
Ejemplo n.º 2
0
  public void addWidget(Actor actor, Color color) {
    actor.setTouchable(Touchable.disabled);

    if (actor instanceof Table) {
      ((Table) actor).setTransform(true);
    }
    widgets.add(actor);
    colors.add(color);

    if (getActor() == null) {
      setActor(actor);
      setColor(color == null ? style.color : color);
      toShow = actor;
      actor.setTouchable(Touchable.enabled);
    }
  }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
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.");
    }
  }
Ejemplo n.º 5
0
  @Override
  public void show() {
    super.show();

    backgroundStage.addActor(new Image(atlas.findRegion("background")));

    Image alien = new Image(atlas.findRegion("alien"));
    alien.setPosition(mainStage.getWidth() + mainStage.getPadLeft(), -365f);
    mainStage.addActor(alien);

    Image energy = new Image(atlas.findRegion("energy")); // 195, 313
    energy.setPosition(83f, 201f);
    energy.setScale(0f);
    energy.setOrigin(energy.getPrefWidth() / 2, energy.getPrefHeight() / 2);
    mainStage.addActor(energy);

    final Table certificateTable = new Table();
    certificateTable.padTop(314f).padBottom(101f).defaults().padBottom(100f);
    certificateTable.setBackground(new TextureRegionDrawable(atlas.findRegion("certificate")));
    certificateTable.setSize(mainStage.getWidth(), mainStage.getHeight());
    certificateTable.setOrigin(195f, 313f);
    certificateTable.setTransform(true);
    certificateTable.setTouchable(Touchable.disabled);
    certificateTable.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Assets.fanfareFX.stop();
            game.loadNextScreen(EndingScreen.this, KonnectingGame.ScreenType.MAIN_MENU);
          }
        });
    certificateTable.setScale(0f);
    mainStage.addActor(certificateTable);

    StatsData tempData = SavedData.getStats();
    int score =
        tempData.kronosScore1
            + tempData.kronosScore2
            + tempData.kronosScore3
            + tempData.kronosScore4
            + tempData.kronosScore5
            + tempData.kronosScore6
            + tempData.kronosScore7
            + tempData.zappingScore1
            + tempData.zappingScore2
            + tempData.zappingScore3
            + tempData.zappingScore4
            + tempData.zappingScore5;

    final Label userLabel =
        new Label(
            SavedData.getUsername() + "\n\n" + score + "pt",
            new Label.LabelStyle(uiSkin.getFont("default-font"), Color.WHITE));
    userLabel.setWrap(true);
    userLabel.setAlignment(Align.center);
    userLabel.getColor().a = 0f;
    certificateTable.add(userLabel).width(407f).row();

    String correctComment = comments[0];
    for (int i = scoreLimits.length - 1; i >= 0; i--) {
      if (score > scoreLimits[i]) {
        correctComment = comments[i];
        break;
      }
    }
    final Label commentLabel =
        new Label(correctComment, new Label.LabelStyle(uiSkin.getFont("arial"), Color.WHITE));
    commentLabel.setWrap(true);
    commentLabel.setFontScale(0.9f);
    commentLabel.setAlignment(Align.center);
    commentLabel.getColor().a = 0f;
    certificateTable.add(commentLabel).width(407f);

    Timeline.createSequence()
        .push(Tween.to(alien, ActorAccessor.MOVE_X, 1f).target(20f))
        .pushPause(0.25f)
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 1f).target(1f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(0.8f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .push(Tween.to(certificateTable, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .beginParallel()
        .push(Tween.to(userLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .push(Tween.to(commentLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .end()
        .setCallback(
            new TweenCallback() {
              @Override
              public void onEvent(int type, BaseTween<?> source) {
                Assets.fanfareFX.setOnCompletionListener(
                    new Music.OnCompletionListener() {
                      @Override
                      public void onCompletion(Music music) {
                        Assets.fanfareFX.setOnCompletionListener(null);
                        certificateTable.setTouchable(Touchable.enabled);
                      }
                    });
                Assets.fanfareFX.play();
              }
            })
        .start(tweenManager);
  }