Пример #1
0
  public AotHudGameOver(Skin sk) {
    _skin = sk;
    Label gameover = new Label("GAME OVER", _skin.get("JUNEBUG_32", LabelStyle.class));
    _retry = new Label(">> RETRY <<", _skin.get("JUNEBUG_16", LabelStyle.class));
    _lvlselect = new Label(">> LEVEL SELECTION <<", _skin.get("JUNEBUG_16", LabelStyle.class));

    _retry.setPosition(0, 0);
    _lvlselect.setPosition(_retry.getWidth() + 100, 0);

    this.setWidth(_retry.getWidth() + _lvlselect.getWidth() + 100);

    gameover.setPosition((this.getWidth() - gameover.getWidth()) / 2, _retry.getHeight() + 100);

    this.setHeight(_retry.getHeight() + gameover.getHeight() + 100);

    addActor(gameover);
    addActor(_retry);
    addActor(_lvlselect);

    this.setPosition(
        (AbstractScreen.GAME_VIEWPORT_WIDTH - this.getWidth()) / 2,
        (AbstractScreen.MENU_VIEWPORT_HEIGHT - this.getHeight()) / 2 - 100);

    _lvlselect.addListener(this);
    _retry.addListener(this);
  }
Пример #2
0
  @Override
  protected Label updateLabel(Player player, Type index, final String text) {
    super.updateLabel(player);
    final Map<Player, Table> labels = getLabelMap();
    final Label label = (Label) labels.get(player).getChildren().get(index.type);
    final EventListener first = label.getListeners().first();

    label.clearListeners();
    label.addListener(first);

    if (index == Type.PLAYER) label.addListener(getListener(player));

    final Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            label.setText(text);
          }
        };

    final SequenceAction sequence =
        Actions.sequence(
            Actions.fadeOut(getSpeed()), Actions.run(runnable), Actions.fadeIn(getSpeed()));
    label.addAction(sequence);

    return label;
  }
Пример #3
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }
  public StatusBarPanel() {
    setTouchable(Touchable.childrenOnly);

    moneyLabel = makeValueLabel("0");
    moneyIncomeLabel = makeValueLabel("0");
    moneyExpensesLabel = makeValueLabel("0");
    experienceLabel = makeValueLabel("0");
    populationLabel = makeValueLabel("0");
    employmentLabel = makeValueLabel("0");
    gameSpeedLabel = makeValueLabel(SceneManager.activeScene().getTimeMultiplier() + "x");
    starRatingBar = new RatingBar(0, 5);

    whiteSwatch = TowerAssetManager.texture(TowerAssetManager.WHITE_SWATCH);
    backgroundTexture = TowerAssetManager.texture("hud/window-bg.png");
    backgroundTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    defaults();
    center();

    // TODO these need to be moved to the resources file
    row().pad(devicePixel(2)).padBottom(0);
    add(makeHeader("MONEY", Color.LIGHT_GRAY)).center();
    add(makeHeader("INCOME", Color.LIGHT_GRAY)).center();
    add(makeHeader("EXPENSES", Color.LIGHT_GRAY)).center();
    add(makeHeader("POPULATION", Color.LIGHT_GRAY)).center();
    add(makeHeader("EMPLOYMENT", Color.LIGHT_GRAY)).center();
    Label gameSpeedHeader = makeHeader("GAME SPEED", Color.LIGHT_GRAY);
    add(gameSpeedHeader).center();
    Label starRatingHeader = makeHeader("STAR RATING", Color.LIGHT_GRAY);
    add(starRatingHeader).center();

    row().pad(devicePixel(2)).padTop(0);
    add(moneyLabel);
    add(moneyIncomeLabel);
    add(moneyExpensesLabel);
    add(populationLabel);
    add(employmentLabel);
    add(gameSpeedLabel);
    add(starRatingBar);

    if (TowerConsts.ENABLE_NEWS_TICKER) {
      row().pad(devicePixel(2)).padLeft(devicePixel(-4)).padRight(devicePixel(-4));
      add(new HorizontalRule(Colors.ICS_BLUE_SEMI_TRANSPARENT, 1)).fillX().colspan(7);

      row().pad(0);
      add(new NewsTickerPanel()).colspan(7).left();
    }

    dubai7StarWonder = AchievementEngine.instance().findById("dubai-7-star-wonder");

    gameSpeedOverlay = new PopOver();
    gameSpeedOverlay.alignArrow(Align.left);
    gameSpeedOverlay
        .add(new Image(TowerAssetManager.textureFromAtlas("snail", "hud/buttons.txt")))
        .center();
    gameSpeedSlider =
        new Slider(
            TowerConsts.GAME_SPEED_MIN,
            TowerConsts.GAME_SPEED_MAX,
            0.5f,
            false,
            TowerAssetManager.getCustomSkin());
    gameSpeedOverlay.add(gameSpeedSlider).width(devicePixel(150));
    gameSpeedOverlay
        .add(new Image(TowerAssetManager.textureFromAtlas("rabbit", "hud/buttons.txt")))
        .center();
    gameSpeedOverlay.pack();
    gameSpeedOverlay.setVisible(false);

    gameSpeedSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float remainder = gameSpeedSlider.getValue() * 2f / 2f;
            SceneManager.activeScene().setTimeMultiplier(remainder);
          }
        });

    SceneManager.activeScene().events().register(this);

    starRatingPopOver = new TowerRatingPopOver();
    starRatingPopOver.setVisible(false);

    pack();

    VibrateClickListener gameSpeedToggleListener =
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            gameSpeedOverlay.toggle(StatusBarPanel.this, gameSpeedLabel);
          }
        };
    gameSpeedHeader.addListener(gameSpeedToggleListener);
    gameSpeedLabel.addListener(gameSpeedToggleListener);

    VibrateClickListener starRatingListener =
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            starRatingPopOver.toggle(StatusBarPanel.this, starRatingBar);
          }
        };
    starRatingHeader.addListener(starRatingListener);
    starRatingBar.addListener(starRatingListener);

    setTouchable(Touchable.enabled);
    addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {}
        });
  }