Exemplo n.º 1
0
  private static void createOptionsGroup() {
    optionsGroup = new Group();
    optionsGroup.setVisible(false);
    final OptionsPanel p = new OptionsPanel(AbstractScreen.skin, "dialog");
    p.setName(OPTIONS_PANEL_NAME);
    final Button options = new ImageButton(AbstractScreen.skin, "ic_settings");
    options.setBounds(
        AbstractScreen.stagew - OPTIONS_BUTTON_WIDTH_HEIGHT,
        AbstractScreen.stageh - OPTIONS_BUTTON_WIDTH_HEIGHT,
        OPTIONS_BUTTON_WIDTH_HEIGHT,
        OPTIONS_BUTTON_WIDTH_HEIGHT);
    options.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            if (!p.isVisible()) {
              AbstractScreen.mockupController.show(p);
            } else {
              AbstractScreen.mockupController.hide(p);
            }
          }
        });
    TextureRegion t = AbstractScreen.skin.getRegion("ic_logo");

    Image i = new Image(t);
    i.setTouchable(Touchable.disabled);
    i.setX(AbstractScreen.halfstagew - t.getRegionWidth() / 2f);
    i.setY(AbstractScreen.halfstageh * 1.1f - t.getRegionHeight() / 2f);

    optionsGroup.addActor(i);
    optionsGroup.addActor(p);
    optionsGroup.addActor(options);
  }
Exemplo n.º 2
0
  @Override
  public void onUse() {
    if (GemLord.getInstance().gameScreen.getBoard().getBoardState() != Board.BoardState.STATE_IDLE)
      return;
    if (!GemLord.getInstance().gameScreen.getBoard().isPlayerTurn()) return;

    if (currentCooldown <= 0) {
      GemLord.soundPlayer.playBow();
      int damage = random.nextInt(((35 - 20) + 1));
      damage += 20;

      Damage dmg = new Damage();
      dmg.damage = damage;
      GemLord.getInstance().gameScreen.getBoard().getEnemy().damage(dmg);
      addAction(Actions.sequence(Actions.scaleTo(2f, 2f, 0.15f), Actions.scaleTo(1f, 1f, 0.15f)));
      currentCooldown = cooldown;
      TextureAtlas atlas = GemLord.assets.get("data/textures/pack.atlas", TextureAtlas.class);
      Image projectile = new Image(atlas.findRegion("itemarrow"));
      projectile.setPosition(getX(), getY());

      float targetX = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getX();
      float targetY = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getY();

      projectile.addAction(
          Actions.sequence(
              Actions.moveTo(targetX, targetY, 0.25f),
              Actions.fadeOut(0.25f),
              Actions.removeActor()));

      GemLord.getInstance().gameScreen.getBoard().getEffectGroup().addActor(projectile);
    }
  }
Exemplo n.º 3
0
  private void timee(float delta) {
    if (level_count >= LEVEL_NUM) {
      return;
    }

    passtime -= delta;
    if (passtime > 0) {
      return;
    }

    if (showing) {
      showing = false;
      passtime = GAP_SEC;

      if (curShowN >= 0) {
        Image img = images.get(curShowN);
        img.setColor(origColor);
        curShowN = -1;
      }
    } else {
      level_count++;
      showing = true;
      passtime = SHOW_SEC;
      curShowN = Utils.random(images.size());
      Image img = images.get(curShowN);
      img.setColor(Color.GREEN);
    }
  }
Exemplo n.º 4
0
  private GameScreen() {
    this.superflu = SuperFlu.getInstance();
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    groupZones = new Group();
    groupVilles = new GroupVilles();
    groupTransferts = new Group();

    Texture backgroundTexture = superflu.manager.get("images/fond_carte.png", Texture.class);
    TextureRegion backgroundTextureRegion =
        new TextureRegion(backgroundTexture, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
    Image imgBackground = new Image(backgroundTextureRegion);
    imgBackground.touchable = false;
    stage.addActor(imgBackground);

    Texture carteTexture = superflu.manager.get("images/carte.png", Texture.class);
    TextureRegion carteTextureRegion =
        new TextureRegion(carteTexture, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
    Image carte = new Image(carteTextureRegion);
    carte.touchable = false;
    stage.addActor(carte);

    stage.addActor(groupZones);
    stage.addActor(groupVilles);
    stage.addActor(groupTransferts);

    stage.addActor(TransfertCreator.getInstance());

    Music softMusic = superflu.manager.get("music/soft.mp3", Music.class);
    softMusic.play();

    createEntities();
    Gdx.input.setInputProcessor(stage);

    stage.addActor(new GlobalStatsActor(gameLogic));
  }
  public void flip() {
    frontImage.addAction(Actions.scaleTo(0, 1, DURATION / 2));
    backImage.addAction(Actions.delay(DURATION / 2));
    backImage.addAction(Actions.scaleTo(1, 1, DURATION / 2));

    flipped = true;
  }
Exemplo n.º 6
0
  public void spawnSnowflake() {
    final Image snowflake = new Image(snow);
    snowflake.setOrigin(64, 64);
    int x = (int) (Math.random() * 800);
    snowflake.setPosition(x, 480);
    snowflake.setScale((float) (Math.random() * 0.8f + 0.2f));
    snowflake.addAction(
        parallel(
            forever(rotateBy(360, (float) (Math.random() * 6))),
            sequence(
                moveTo(x, 0, (float) (Math.random() * 15)),
                fadeOut((float) (Math.random() * 1)),
                new Action() { // we
                  // can
                  // define
                  // custom
                  // actions
                  // :)

                  @Override
                  public boolean act(float delta) {
                    snowflake.remove(); // delete this snowflake
                    spawnSnowflake(); // spawn a new snowflake
                    return false;
                  }
                })));
    stage.addActor(snowflake);
  }
  @Override
  public void set(byte index, Inventory inventory) {
    SlotElement slot = m_slots[index];

    Entity item = inventory.item(index);
    ItemComponent itemComponent = itemMapper.get(item);
    m_slots[index].itemCountLabel.setText(Integer.toString(itemComponent.stackSize));

    TextureRegion region;
    SpriteComponent spriteComponent = spriteMapper.get(item);
    if (blockMapper.get(item) != null) {
      // hack
      region =
          m_client.m_world.m_tileRenderer.m_tilesAtlas.findRegion(
              spriteComponent.textureName.concat("-00"));
    } else {
      region = m_client.m_world.m_atlas.findRegion(spriteComponent.textureName);
    }

    Image slotImage = slot.itemImage;
    //        //m_blockAtlas.findRegion("stone"));
    slotImage.setDrawable(new TextureRegionDrawable(region));
    slotImage.setSize(region.getRegionWidth(), region.getRegionHeight());
    slotImage.setScaling(Scaling.fit);

    setHotbarSlotVisible(index, true);

    // do not exceed the max size/resort to horrible upscaling. prefer native size of each inventory
    // sprite.
    // .maxSize(region.getRegionWidth(), region.getRegionHeight()).expand().center();

  }
  public void removeFromStage() {
    frontImage.addAction(Actions.scaleTo(1, 0));
    backImage.addAction(Actions.delay(DURATION));
    backImage.addAction(Actions.scaleTo(1, 0, DURATION));

    frontImage.remove();
    backImage.remove();
  }
Exemplo n.º 9
0
  /** Sets the loading to finished and displays the finished loading message. */
  public void loadingFinished() {
    if (!progressLabel.getText().equals(ON_FINISHED_LABEL_TEXT)) {
      progressLabel.setText(ON_FINISHED_LABEL_TEXT);
      centerProgressLabel();

      loadBar.setScaleX(1);
      loadBar.invalidate();
    }
  }
Exemplo n.º 10
0
 private Table buildBackgoundLayer() {
   Table layer = new Table();
   imgBackgound = new Image(skinCanyonBunny, "map");
   imgBackgound.setScale(Constants.SCALE);
   layer.add(imgBackgound);
   imgBackgound.setColor(
       imgBackgound.getColor().r, imgBackgound.getColor().g, imgBackgound.getColor().b, 0.2f);
   return layer;
 }
Exemplo n.º 11
0
 @Override
 public void layout() {
   image.setPosition(0, 0);
   image.setSize(64, 64);
   txtName.setPosition(64, getPrefHeight() - txtName.getPrefHeight() - 5);
   txtName.setSize(txtName.getPrefWidth(), txtName.getPrefHeight());
   txtSoul.setPosition(64, txtName.getY() - txtSoul.getPrefHeight() + 5);
   txtSoul.setSize(txtSoul.getPrefWidth(), txtSoul.getPrefHeight());
 }
Exemplo n.º 12
0
  public SplashScreen(TestGame pGame) {
    game = pGame;

    tree =
        new Texture(
            Gdx.files.internal(
                "graphics/tree.png")); // http://openclipart.org/detail/1936/tree-by-harmonic
    christmasTree = new TextureRegion(tree, 0, 0, 450, 730);
    ball =
        new Texture(
            Gdx.files.internal(
                "graphics/ball.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738
    snow =
        new Texture(
            Gdx.files.internal(
                "graphics/snow.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738

    font = new BitmapFont(Gdx.files.internal("ui/test.fnt"), false);

    stage = new Stage();

    // our christmas tree
    Image ctree = new Image(christmasTree);
    ctree.setSize(296, 480); // scale the tree to the right size
    ctree.setPosition(-300, 0);
    ctree.addAction(moveTo(400 - 148, 0, 1f));
    ctree.setZIndex(0);
    stage.addActor(ctree);

    Image ballImage = new Image(ball);
    ballImage.setPosition(400 - 148 + 60, 170);

    ballImage.setOrigin(32, 32);
    ballImage.setColor(1, 1, 1, 0);
    ballImage.addAction(
        sequence(
            delay(1),
            parallel(fadeIn(1), rotateBy(360, 1)),
            delay(2f),
            new Action() {
              // custom action to switch to the menu screen
              @Override
              public boolean act(float delta) {
                game.setScreen(new MenuScreen(game));
                return false;
              }
            }));

    stage.addActor(ballImage);

    // create the snowflakes
    for (int i = 0; i < 10; i++) {
      spawnSnowflake();
    }
  }
Exemplo n.º 13
0
  public GameOverScreen(Start game, int score) {

    line = "";

    // get previous file contents
    try {
      Scanner scanner = new Scanner(new FileReader("scores.txt"));
      while (scanner.hasNextLine()) {
        line += scanner.nextLine() + "\n";
      }

      scanner.close();
    } catch (FileNotFoundException e) {
      // file not found
    }

    // add new content
    try {

      String content = line + Integer.toString(score);

      File file = new File("scores.txt");

      if (!file.exists()) {
        file.createNewFile();
      }

      FileWriter fw = new FileWriter(file.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);
      bw.write(content);
      bw.close();

    } catch (IOException e) {
      // no line found
    }

    gameScreen = new GameScreen(game, updateHighScore());
    introScreen = new IntroScreen(game);

    this.game = game;
    stage = new Stage();
    batch = new SpriteBatch();

    gameOverTexture = new Texture("gameOver.png");
    playAgainTexture = new Texture("playAgain.png");
    gameOver = new Image(gameOverTexture);
    playAgain = new Image(playAgainTexture);

    gameOver.setPosition(Gdx.graphics.getWidth() / 10, Gdx.graphics.getHeight() / 10);
    playAgain.setPosition(Gdx.graphics.getWidth() / 10, -Gdx.graphics.getHeight() / 2);

    first = true;
  }
Exemplo n.º 14
0
  public Modul(Spiel spiel) {
    this.skin = spiel.gebeSkin();
    this.spiel = spiel;

    addActor(new Image(skin, "Modul"));
    addActor(new Image(skin, "Gitter"));

    this.imageLED = new Image(skin, "LED");
    imageLED.setPosition(BREITE - imageLED.getWidth() - 3, HOEHE - imageLED.getHeight() - 3);
    addActor(imageLED);

    setSize(BREITE, HOEHE);
  }
Exemplo n.º 15
0
 private void fillGroup(Group group, Texture texture) {
   float advance = 32 + SPACING;
   for (int y = 0; y < NUM_SPRITES * advance; y += advance)
     for (int x = 0; x < NUM_SPRITES * advance; x += advance) {
       Image img = new Image(new TextureRegion(texture));
       img.setAlign(Align.center);
       img.setScaling(Scaling.none);
       img.setBounds(x, y, 32, 32);
       img.setOrigin(16, 16);
       group.addActor(img);
       images.add(img);
     }
 }
Exemplo n.º 16
0
  /**
   * Sets the displayed loadProgress.
   *
   * @param loadProgress the current load progress, in percentage from 0 to 1.
   */
  public void setLoadProgress(float loadProgress) {
    percent = Interpolation.linear.apply(percent, loadProgress, 0.1f);

    progressLabel.setText(String.format(PROGRESS_LABEL_TEXT, (int) Math.floor(percent * 100)));
    centerProgressLabel();

    // The width scaling is applied from the middle, resulting in non-transparent parts of the
    // loading bar overlapping the loading bar background. The below is an attempt to counter
    // that.
    float xPercent = 1 - Math.min((float) (percent / 0.5), 1);
    loadBar.setX(loadBarBg.getX() + 4 * xPercent);

    loadBar.setScaleX(percent);
    loadBar.invalidate();
  }
Exemplo n.º 17
0
  private AboutScreen() {
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    superflu = SuperFlu.getInstance();
    credits = superflu.manager.get("images/credits.png", Texture.class);

    Texture backgroundTexture = superflu.manager.get("images/fond_carte.png", Texture.class);
    TextureRegion backgroundTextureRegion =
        new TextureRegion(backgroundTexture, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
    Image imgBackground = new Image(backgroundTextureRegion);
    imgBackground.touchable = false;
    stage.addActor(imgBackground);

    stage.addActor(new Image(credits));
    stage.addActor(new Dna());
  }
Exemplo n.º 18
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.");
    }
  }
Exemplo n.º 19
0
 @Override
 public void update(double population) {
   float size = ((float) population / 10000) + 20;
   if (size < MIN_SIZE) size = MIN_SIZE;
   else if (size > MAX_SIZE) size = MAX_SIZE;
   settlementImage.setSize(size, size);
 }
Exemplo n.º 20
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.");
    }
  }
Exemplo n.º 21
0
 public Challenge(int level, int gateNum) {
   float space = Assets.WIDTH / 6;
   Integer[] bmpIds = Answer.CHALLENGES[gateNum];
   List<Sprite> sprites = Assets.levelSpriteMap.get(level);
   float x_off = Assets.WIDTH / 40;
   float y_off = Assets.TOPBAR_HEIGHT;
   int off = bmpIds.length - 1;
   for (int i = off; i >= 0; i--) {
     Image image = new Image(sprites.get(bmpIds[i]));
     float y = y_off + (-i / 3 + 2) * space;
     float x = x_off + i % 3 * space;
     image.setBounds(x, y, Assets.PIECE_SIZE / 3, Assets.PIECE_SIZE / 3);
     addActor(image);
   }
   isDraw = true;
 }
Exemplo n.º 22
0
  public LoadingStage() {
    initViewport();

    // Get our textureatlas from the manager, then get assets
    TextureAtlas atlas = Game.GDXVars().getTextureAtlas(Paths.loadingPack);
    font = Game.GDXVars().getFont(Paths.defaultFont);

    // Create actors
    background = new Image(Game.GDXVars().getTexture(Paths.splashBackground));
    background.setSize(getWidth(), getHeight());
    loadingBar = new LoadingBar(atlas);
    loadingBar.setPosition(getWidth() / 2 - loadingBar.getWidth() / 2, loadingBar.getHeight() / 2f);

    // Add actors
    addActor(background);
    addActor(loadingBar);

    // Selection group
    selector =
        new AtlasSelector(
            Game.GDXVars().getTextureAtlas(Paths.charactersPack), Game.Save().characters);
    addActor(selector);
    selector.setPosition(getWidth() / 2f - selector.getWidth() / 2f, 130);

    progress = 0f;

    // Start the work
    startLoadingWork();
  }
Exemplo n.º 23
0
  private void init(String text, Image image, MenuItemStyle style) {
    this.style = style;
    this.image = image;
    setSkin(VisUI.getSkin());
    Sizes sizes = getSkin().get(Sizes.class);

    defaults().space(3);

    if (image != null) image.setScaling(Scaling.fit);
    add(image).size(sizes.menuItemIconSize);

    label = new Label(text, new LabelStyle(style.font, style.fontColor));
    label.setAlignment(Align.left);
    add(label).expand().fill();

    add(shortcutLabel = new VisLabel("", "menuitem-shortcut")).padLeft(10).right();
    shortcutLabelColor = shortcutLabel.getStyle().fontColor;

    subMenuIconCell =
        add(subMenuImage = new Image(style.subMenu))
            .padLeft(3)
            .padRight(3)
            .size(style.subMenu.getMinWidth(), style.subMenu.getMinHeight());
    subMenuIconCell.setActor(null);

    addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            // makes submenu item not clickable
            if (subMenu != null) event.stop();
          }
        });

    addListener(
        new InputListener() {
          @Override
          public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
            if (subMenu == null || isDisabled()) {
              // hides last visible submenu (if any)
              PopupMenu parent = (PopupMenu) getParent();
              parent.setSubMenu(null);
            } else {
              Stage stage = getStage();
              Vector2 pos = localToStageCoordinates(new Vector2(0, 0));

              subMenu.setPosition(
                  pos.x + getWidth() - 1, pos.y - subMenu.getHeight() + getHeight());
              if (subMenu.getY() < 0) {
                subMenu.setY(subMenu.getY() + subMenu.getHeight() - getHeight());
              }

              stage.addActor(subMenu);

              PopupMenu parent = (PopupMenu) getParent();
              parent.setSubMenu(subMenu);
            }
          }
        });
  }
Exemplo n.º 24
0
  public FinalDialogueScreen(final ButtonGame game) {
    this.game = game;
    stage = new Stage(new ScreenViewport());

    dialogueLabel = new Label("", Resources.Skin());
    dialogueLabel.setWrap(true);
    dialogueLabel.setColor(Color.CYAN);

    leftPerson = new Image(new Texture(Gdx.files.internal("graphics/CaptainCalamari.png")));
    leftPerson.setVisible(false);
    rightPerson = new Image(new Texture(Gdx.files.internal("graphics/JimmyTwoButton.png")));
    leftPerson.setScaling(Scaling.none);
    rightPerson.setScaling(Scaling.none);
    stage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(
              InputEvent event, float screenX, float screenY, int pointer, int button) {

            if (count < maxCount) {
              count = advanceDialogue(count);
            } else {
              game.startLevel(Level.get(game, 10));
            }
            return true;
          }
        });

    Table table = new Table();
    table.setFillParent(true);
    table.align(Align.top);
    table.add().height(50).colspan(3).center();
    table.row();
    table.add(leftPerson);
    table.add(); // .width(20);
    table.add(rightPerson);
    table.row();
    table.add().colspan(3).height(50);
    table.row();
    table.add(dialogueLabel).width(600).colspan(3).center();
    if (Resources.DEBUG) {
      table.setDebug(true);
    }

    stage.addActor(table);
  }
Exemplo n.º 25
0
  public void initComponents() {
    stage.clear();

    background =
        new Image(
            new TextureRegion(
                new Texture(
                    Gdx.files.internal(
                        FileMap.resourcesToDirectory.get("game_ui_images")
                            + "logo_shadow_struggles.png")),
                512,
                512));
    background.setScaleX(960f / 512f);
    background.setScaleY(640f / 512f);
    background.setY(background.getImageY() + 100);

    stage.addActor(background);
  }
 public Card(int type, Texture texture, String quality, boolean golden) {
   this.type = type;
   this.backImage = new Image(texture);
   backImage.addAction(Actions.scaleTo(0, 1));
   this.width = texture.getWidth();
   this.height = texture.getHeight();
   this.quality = quality;
   this.golden = golden;
 }
Exemplo n.º 27
0
 public int advanceDialogue(int currCount) {
   dialogueLabel.setText(Resources.getInstance().finalDialogue[currCount]);
   dialogueLabel.setColor(Resources.getInstance().finalDialogueColor[currCount]);
   dialogueLabel.setAlignment(Resources.getInstance().finalDialogueAlign[currCount]);
   if (currCount == 2) {
     leftPerson.setVisible(true);
   }
   return count + 1;
 }
  public void addToStage(Stage stage, int x, int y, int width, int height) {

    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;

    System.out.println("Drawn at " + x + " " + y + " Dimensions " + width + " " + height);

    Texture texture = new Texture(Gdx.files.internal("Fuego_Back.png"));
    frontImage = new Image(texture);
    frontImage.setSize(width, height);
    frontImage.setPosition(x, y);

    backImage.setPosition(x, y);
    backImage.setSize(Gdx.graphics.getWidth() / 2, Gdx.graphics.getWidth() / 2 * 4 / 3);
    backImage.addAction(Actions.scaleTo(0, 1));
    stage.addActor(frontImage);
    stage.addActor(backImage);
  }
Exemplo n.º 29
0
 private void updateFreeze() {
   freezers = LevelData.freezers;
   freezes.setText(String.valueOf(freezers));
   imgFreeze.addAction(
       Actions.sequence(
           Actions.scaleTo(0f, 0f),
           Actions.alpha(1f),
           Actions.parallel(
               Actions.rotateBy(360f, 0.7f),
               Actions.scaleTo(1f, 1f, 0.5f),
               Actions.alpha(0f, 1.0f, Interpolation.circleIn))));
 }
Exemplo n.º 30
0
 @Override
 public void show() {
   initSplashManager();
   splashImage.addAction(
       Actions.sequence(
           Actions.sequence(
               Actions.fadeIn(0.75f),
               Actions.delay(2.75f),
               Actions.fadeOut(0.75f),
               Actions.run(onFirstSplashFinishedRunnable))));
   splashStage.addActor(splashImage);
 }