Exemplo 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");
                      }
                    }))));
  }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
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);
 }
 @Override
 public void layout() {
   super.layout();
   panXOffset = (int) (getWidth() * panXOffsetFactor);
 }
Exemplo n.º 6
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();
  }
Exemplo n.º 7
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.");
    }
  }
Exemplo n.º 8
0
  // constructor --------------------------------------------------------------------------
  public ScoreBoardScreen(EndMissionReport missionData) {
    super();

    // table setup
    // *******************************************************************************************************
    int score = 0;
    boolean success = missionData.isSuccess();

    // -- title *******************************************************
    final Label title = new Label(success ? "Success" : "Failure", menuSkin, "title");
    table.add(title).padTop(50).padBottom(40).padLeft(10).padRight(10).center().colspan(2);

    // -- team summary ************************************************
    table.row().padBottom(10);
    final Label teamHeader = new Label("Team", menuSkin, "subTitle");
    table.add(teamHeader).padLeft(20).spaceRight(40).left();

    HorizontalGroup teammates = new HorizontalGroup();
    teammates.space(10);

    int index = 0;
    for (int i = 0; i < missionData.safeMates.size; i++) {
      Image image =
          new Image(menuSkin.getDrawable(missionData.safeMates.get(i).getItemRegionName(false)));
      teammates.addActorAt(index, image);
      index++;
    }

    for (int i = 0; i < missionData.lostMates.size; i++) {
      Image image =
          new Image(menuSkin.getDrawable(missionData.lostMates.get(i).getItemRegionName(true)));
      teammates.addActorAt(index, image);
      score += LOST_MATE_SCORE;
      index++;
    }
    teammates.pack();
    table.add(teammates).padRight(20).center();

    // -- substance summary ************************************************

    table.row().padBottom(10);
    final Label harvestHeader = new Label("Harvest", menuSkin, "subTitle");
    table.add(harvestHeader).padLeft(20).spaceRight(40).left();
    HorizontalGroup substances = new HorizontalGroup();
    substances.space(10);

    if (missionData.collectedSubstance > 0) {

      Image banner = new Image(menuSkin.getDrawable("banner" + missionData.collectedSubstance));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_substance")));
      stack.addActor(banner);
      score += SUBSTANCE_SCORE * missionData.collectedSubstance;

      substances.addActor(stack);
    }

    if (missionData.targetSubstance - missionData.collectedSubstance > 0) {
      Image banner =
          new Image(
              menuSkin.getDrawable(
                  "banner" + (missionData.targetSubstance - missionData.collectedSubstance)));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_outSubstance")));
      stack.addActor(banner);

      substances.addActor(stack);
    }

    table.add(substances).padRight(20).center();

    // consumption summary ************************************************
    table.row().padBottom(10);
    final Label usedHeader = new Label("Used", menuSkin, "subTitle");
    table.add(usedHeader).padLeft(20).spaceRight(40).left();

    HorizontalGroup collectibles = new HorizontalGroup();
    collectibles.space(10);

    score += USED_SUPPLY_SCORE * missionData.usedSupply;
    int itemCount = missionData.usedSupply / 10;

    // supplies *******
    for (int i = 0; i < itemCount; i++) {
      Image banner = new Image(menuSkin.getDrawable("banner10"));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_supply")));
      stack.addActor(banner);
      collectibles.addActor(stack);
    }

    int extraItems = missionData.usedSupply % 10;
    if (extraItems > 0) {
      Image banner = new Image(menuSkin.getDrawable("banner" + extraItems));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_supply")));
      stack.addActor(banner);
      collectibles.addActor(stack);
    }

    // materials *******
    score += USED_MATERIAL_SCORE * missionData.usedMaterial;
    itemCount = missionData.usedMaterial / 10;

    for (int i = 0; i < itemCount; i++) {
      Image banner = new Image(menuSkin.getDrawable("banner10"));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_material")));
      stack.addActor(banner);
      collectibles.addActor(stack);
    }

    extraItems = missionData.usedMaterial % 10;
    if (extraItems > 0) {
      Image banner = new Image(menuSkin.getDrawable("banner" + extraItems));
      banner.setScaling(Scaling.none);
      banner.setAlign(Align.bottomRight);

      Stack stack = new Stack();
      stack.addActor(new Image(menuSkin.getDrawable("item_material")));
      stack.addActor(banner);
      collectibles.addActor(stack);
    }

    collectibles.pack();

    // -- time bonus summary ************************************************
    table.add(collectibles).padRight(20).center();
    table.row().padBottom(10);
    final Label timeHeader = new Label("Time Bonus", menuSkin, "subTitle");
    table.add(timeHeader).padLeft(20).spaceRight(40).left();

    float timeBonus;

    if (missionData.missionTimeLeft <= 0f) {
      timeBonus = TIMEUP_SCOREMULT;
    } else if (missionData.missionTimeLeft <= 60f) {
      timeBonus = ONTIME_SCOREMULT;
    } else if (missionData.missionTimeLeft <= 120f) {
      timeBonus = GOODTIME_SCOREMULT;
    } else timeBonus = GREATTIME_SCOREMULT;

    table.add(new Label("x" + timeBonus, menuSkin, "title")).padRight(10).center();

    // -- score summary *****************************************************
    table.row().padTop(10).padBottom(50);
    final Label scoreHeader = new Label("Score", menuSkin, "subTitle");
    table.add(scoreHeader).padLeft(20).spaceRight(40).left();

    if (score > 0) score = Math.round(timeBonus * (float) score);
    float maxScore =
        GREATTIME_SCOREMULT
            * Math.min(missionData.targetSubstance, missionData.targetSubstance + 2)
            * SUBSTANCE_SCORE;
    int star_count = Math.max(1, MathUtils.floor(4f * score / maxScore));
    star_count = (!success || missionData.lostMates.size > 0 ? 1 : star_count);

    HorizontalGroup scoreStars = new HorizontalGroup();
    scoreStars.space(5);
    for (int i = 0; i < star_count; i++) {
      Image image = new Image(menuSkin.getDrawable(success ? "goldStar" : "silverStar"));
      scoreStars.addActorAt(i, image);
    }

    table.add(scoreStars).padRight(10).center();
  }
Exemplo n.º 9
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;
  }