Exemple #1
0
 public void resetTitle() {
   gameover = false;
   title.setPosition(250, 900);
   if (currentState == GameState.TITLE) {
     title.addAction(moveTo(200, 20, 2.0f, Interpolation.bounceOut));
   }
   // show in animation (repeat 0)
   title.getState().setAnimation(0, "idle", true);
 }
Exemple #2
0
 public void setInitialValues() {
   heroTurn = true;
   rolled = false;
   // ktory raz losuje enemy
   enemyOne = false;
   enemyTwo = false;
   // enemy zrollowal
   enemyFail = false;
   gameover = false;
   atakowanie = false;
   pozwolSchowac = false;
   title.setClicked(false);
   mapa.setClicked(false);
 }
Exemple #3
0
  public void fadeOutArena() {
    System.out.println("fade out arena");
    // wyjeb kostki
    for (Dice dice : heroDices) {
      dice.setStopklatka(false);
      dice.setTouchable(Touchable.disabled);
      dice.addAction(moveTo(dice.getX(), -200, 1.0f, Interpolation.fade));
    }
    //
    // wyjeb atakuj
    atakujButton.addAction(moveTo(565, -200, 1.0f, Interpolation.fade));
    // zamknij kotare
    kotaraState.setAnimation(0, "close", false);
    // if (kotaraState.getCurrent(0) == null) {
    // System.out.println("kotara sie zamknela");
    // }
    if (kotaraState.getCurrent(0).isComplete()) {
      System.out.println("REKSIO");
    }

    game.player.playerHp = game.initialHp;
    playerIcon.setHp(game.player.playerHp);
    // generujEnemys();
    title.setClicked(false);
    currentState = GameState.TITLE;
    resetMapa();
    resetTitle();
  }
Exemple #4
0
  public void fadeOutMapa(float daleta) {

    if (!mapa.isClicked() && pozwolSchowac) {
      mapa.setClicked(true);
      game.getBee().play(0.6f);
      // schowaj mape
      mapa.addAction(moveTo(mapaX, -900, 1.0f, Interpolation.fade));
      // otworz kotare
      kotaraState.setAnimation(0, "open", false);

      // uzupelnij();

      // uruchom mechanike rozgrywki
      resetArena();

      // for (Dice dice : heroDices) {
      // dice.setTouchable(Touchable.enabled);
      // dice.setVisible(true);
      // }
    }
  }
Exemple #5
0
 public void fadeOutTitle(float delta) {
   game.getBee().play(0.6f);
   level = MathUtils.random(0, 3);
   // System.out.println("fade out title");
   // hide title
   title.addAction(moveTo(200, 900, 1.0f, Interpolation.fade));
   // show map
   // show in animation (repeat 0)
   mapa.getState().setAnimation(0, "in", false);
   mapa.addAction(
       sequence(
           moveTo(mapaX, mapaY, 2.0f, Interpolation.bounceOut),
           run(
               new Runnable() {
                 public void run() {
                   // after action show idle animation based on actual players
                   // level!
                   mapa.getState().addAnimation(0, "show0", false, 0);
                   if (level == 0) {
                     mapa.getState().addAnimation(0, "show1", false, 0);
                   }
                   if (level == 1) {
                     mapa.getState().addAnimation(0, "show2", false, 0);
                   }
                   if (level == 2) {
                     mapa.getState().addAnimation(0, "show3", false, 0);
                   }
                   if (level == 3) {
                     mapa.getState().addAnimation(0, "show4", false, 0);
                   }
                   // pozwol tutaj schowac mape jesli to potrzebne
                   pozwolSchowac = true;
                   currentState = GameState.MAP;
                 }
               })));
 }
Exemple #6
0
 public void resetMapa() {
   mapa.setClicked(false);
   pozwolSchowac = false;
 }
Exemple #7
0
  public Gamescreen(Jamwteatrze game) {

    this.game = game;

    // set game state

    currentState = GameState.TITLE;
    // currentState = GameState.MAP;
    // currentState = GameState.ARENA;

    batch = new SpriteBatch();
    camera = new OrthographicCamera(1280, 720);
    camera.position.set(camera.viewportWidth / 2f, camera.viewportHeight / 2f, 0);
    viewport = new FitViewport(1280, 720, camera);
    camera.update();

    // spine

    sr = new SkeletonRenderer();
    dr = new SkeletonRendererDebug();
    dr.setBoundingBoxes(false);
    dr.setRegionAttachments(false);

    // stage

    stage = new Stage(viewport, batch);
    stageCharacters = new Stage(viewport, batch);

    Gdx.input.setInputProcessor(stage);

    // ----------------- DEKLARACJE

    playerIcon = new SpineActor(batch, sr, shpr, "characters/goral", true, game.player.playerHp);

    playerIcon.setPosition(-400, 180);
    stageCharacters.addActor(playerIcon);

    generujEnemys();

    // atakuj button

    atakujTex = Assets.manager.get(Assets.atakuj, Texture.class);
    atakujTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    atakujButton = new ImageButton(new SpriteDrawable(new Sprite(atakujTex)));
    atakujButton.setPosition(565, -200);
    atakujButton.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (pulaGracza > 0 && !atakowanie) {
              atakowanie = true;
              System.out.println("atakuj button pressed");
              atakuj();
            }
            return true;
          }
        });

    stage.addActor(atakujButton);

    // gui

    font = Assets.manager.get(Assets.myFont, BitmapFont.class);
    font.getData().setScale(0.7f);
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    scena = Assets.manager.get(Assets.scena, Texture.class);
    scena.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    panel = Assets.manager.get(Assets.panel, Texture.class);
    panel.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // tla

    swiat00tlo = Assets.manager.get(Assets.swiat00tlo, Texture.class);
    swiat00tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat01tlo = Assets.manager.get(Assets.swiat01tlo, Texture.class);
    swiat01tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat02tlo = Assets.manager.get(Assets.swiat02tlo, Texture.class);
    swiat02tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat03tlo = Assets.manager.get(Assets.swiat03tlo, Texture.class);
    swiat03tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    kowadloTex = Assets.manager.get(Assets.kowadloTex, Texture.class);
    kowadloTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // kowadlo = new Sprite(kowadloTex);
    // kowadlo.setPosition(100, 100);

    // DICES

    heroDices = new Array<Dice>();
    enemyDices = new Array<Dice>();

    // ------ generate hero dieces
    heroDices.add(new Dice(this, true));
    heroDices.add(new Dice(this, true));
    // heroDices.add(new Dice(this));

    numberHeroDieces = heroDices.size;
    baseHeroDieces = numberHeroDieces;

    for (Dice dice : heroDices) {
      // dice.debug();
      dice.setTouchable(Touchable.disabled);
      dice.setVisible(false);
      stage.addActor(dice);
    }

    // ------ generate enemy dieces

    enemyDices.add(new Dice(this, false));
    enemyDices.add(new Dice(this, false));

    numberEnemyDieces = enemyDices.size;
    baseEnemyDieces = numberEnemyDieces;

    for (int i = 0; i < enemyDices.size; i++) {
      enemyDices.get(i).setPosition(725 + (i * 133), -150);
      if (!heroTurn) {
        enemyDices.get(i).addAction(moveTo(725 + (i * 133), 37, 1.0f, Interpolation.bounceOut));
      }
    }

    for (Dice dice : enemyDices) {
      // dice.debug();
      stage.addActor(dice);
    }

    // kotara

    kotaraAtlas = new TextureAtlas(Gdx.files.internal("gui/kotara.atlas"));
    kotaraJson = new SkeletonJson(kotaraAtlas);
    kotaraSkeletonData = kotaraJson.readSkeletonData(Gdx.files.internal("gui/kotara.json"));
    kotaraSkeleton = new Skeleton(kotaraSkeletonData);
    kotaraIdleAnimation = kotaraSkeletonData.findAnimation("idle");
    AnimationStateData stateData = new AnimationStateData(kotaraSkeletonData);
    kotaraState = new AnimationState(stateData);
    kotaraState.addAnimation(0, "idle", true, 0);
    kotaraSkeleton.setPosition(-200, -150);

    // title

    title = new SpineButton(batch, sr, "gui/title", "idle", 100, 0, 800, 600);
    // title.debug();
    title.setClicked(false);

    if (currentState == GameState.TITLE) {
      resetTitle();
    }

    // title listeners

    title.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (!title.isClicked() && title.getY() <= 20) {
              title.setClicked(true);
              fadeOutTitle(Gdx.graphics.getDeltaTime());
            }
            return true;
          }
        });

    stage.addActor(title);

    // mapa

    mapa = new SpineButton(batch, sr, "gui/mapa", "show0", 100, 0, 800, 600);
    mapa.setPosition(mapaX, -900);
    // mapa.debug();
    mapa.setClicked(false);

    // mapa listeners TODO!

    mapa.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            fadeOutMapa(Gdx.graphics.getDeltaTime());
            return true;
          }
        });

    stage.addActor(mapa);

    // if (currentState == GameState.ARENA) {
    // resetArena();
    // }
  }