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");
                      }
                    }))));
  }
Example #2
0
  private void rebuildStage() {
    skinCanyonBunny =
        new Skin(
            Gdx.files.internal(Constants.SKIN_TOWERDEFENCE),
            new TextureAtlas(Constants.TEXTURE_ATLAS_UI_TD));

    // builder all layer
    stage.clear();
    Stack stack = new Stack();
    stage.addActor(stack);
    stack.setSize(Constants.VIEWPORT_GUI_WIDTH, Constants.VIEWPORT_GUI_HEIGHT);
    stack.add(buildBackgoundLayer());

    stack.add(buildControlsLayer());
  }
 @Override
 public void add(Actor actor) {
   if (getChildren().size >= 1) {
     actor.setVisible(false);
   }
   super.add(actor);
 }
Example #4
0
  @Override
  public void create() {
    Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

    fpsStringBuilder = new StringBuilder();

    skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    stage = new Stage();
    stage.setDebugAll(DEBUG_STAGE);
    stageWidth = stage.getWidth();
    stageHeight = stage.getHeight();

    Gdx.input.setInputProcessor(new InputMultiplexer(stage));

    Stack stack = new Stack();
    stage.addActor(stack);
    stack.setSize(stageWidth, stageHeight);
    testsTable = new Table();
    stack.add(testsTable);

    // Create behavior selection window
    List<String> testList = createTestList();
    behaviorSelectionWindow = addBehaviorSelectionWindow("Behavior Tree Tests", testList, 0, -1);

    // Set selected test
    changeTest(0);

    fpsLabel = new Label("FPS: 999", skin);
    stage.addActor(fpsLabel);
  }
  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();
  }
  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.");
    }
  }
Example #7
0
  public MenuScreen(DirectedGame game) {
    super(game);

    // FlickrService.instance.getPhotos(1, 1);
    Player.instance.init();

    jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);

    final Table rootTable = new Table();
    rootTable.setFillParent(true);

    howTo = new HowToActor(game);
    credits = new CreditsActor();
    final Actor artTreachery =
        new Image(Assets.instance.skin.getRegion(AssetTextures.artTreachery));

    credits.getColor().a = 0f;

    final Stack mainContainer = new Stack();
    mainContainer.add(howTo);
    mainContainer.add(credits);

    rootTable.add(artTreachery).colspan(2).padTop(20f).row();
    rootTable.add(mainContainer).expand(); // .fill(1f, 1f);
    rootTable.add(buildMenu()).expandY().center().padRight(20f);
    rootTable.row();
    // rootTable.setDebug(true);

    this.stage.addActor(rootTable);

    stage.addListener(
        new InputListener() {

          @Override
          public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
              Gdx.app.exit();
              return true;
            } else if (keycode == Keys.LEFT || keycode == Keys.A) {
              activatePrevButton();
              return true;
            } else if (keycode == Keys.RIGHT || keycode == Keys.D) {
              activateNextButton();
              return true;
            } else if (keycode == Keys.UP || keycode == Keys.W) {
              activatePrevButton();
              return true;
            } else if (keycode == Keys.DOWN || keycode == Keys.S) {
              activateNextButton();
              return true;
            } else if (keycode == Keys.ALT_LEFT
                || keycode == Keys.ALT_RIGHT
                || keycode == Keys.Z
                || keycode == Keys.SPACE) {
              // action button 1
              useActiveButton();
              return true;
            } else if (keycode == Keys.CONTROL_LEFT
                || keycode == Keys.CONTROL_RIGHT
                || keycode == Keys.X
                || keycode == Keys.SHIFT_LEFT
                || keycode == Keys.SHIFT_RIGHT) {
              // action button 2
              useActiveButton();
              return true;
            }
            return super.keyDown(event, keycode);
          }

          private void useActiveButton() {
            final InputEvent event = new InputEvent();
            event.setPointer(0);
            event.setType(Type.touchDown);
            buttons.get(activeButtonIndex).fire(event);
          }

          private void activatePrevButton() {
            InputEvent event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.exit);
            buttons.get(activeButtonIndex).fire(event);

            buttons.get(activeButtonIndex).removeAction(jiggleAction);
            if (activeButtonIndex == 0) {
              activeButtonIndex = buttons.size - 1;
            } else {
              activeButtonIndex--;
            }
            jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);
            buttons.get(activeButtonIndex).addAction(jiggleAction);

            event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.enter);
            buttons.get(activeButtonIndex).fire(event);
          }

          private void activateNextButton() {
            InputEvent event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.exit);
            buttons.get(activeButtonIndex).fire(event);

            buttons.get(activeButtonIndex).removeAction(jiggleAction);
            if (activeButtonIndex == buttons.size - 1) {
              activeButtonIndex = 0;
            } else {
              activeButtonIndex++;
            }
            jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);
            buttons.get(activeButtonIndex).addAction(jiggleAction);

            event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.enter);
            buttons.get(activeButtonIndex).fire(event);
          }
        });

    // ((OrthographicCamera) stage.getCamera()).zoom = 0.5f;
  }